Subject: Re: [boost] [c++TR2] N3334, Proposing array_ref<T> and string_ref
From: Beman Dawes (bdawes_at_[hidden])
Date: 2012-01-30 10:37:23
On Mon, Jan 30, 2012 at 9:30 AM, Roman Perepelitsa
> 2012/1/30 Beman Dawes <bdawes_at_[hidden]>
>> One of my blink reactions is that array_ref<T> and
>> basic_string_ref<charT, traits> are range generators and I was a bit
>> surprised to see the implementation was a pointer and length rather
>> than two pointers.
> Implements are free to use two pointers if that's faster on some platform.
>> Or better yet, two iterators or an explicit range
>> component. With iterators, a basic_string_ref could do encoding
>> conversions on-the-fly without need of temporary strings. But I have
>> no idea if that is workable or actually is better.
> I don't see how this could work unless each access to basic_string_ref
> involves a virtual function call or all functions accepting
> basic_string_ref must be templates.
> function that accepts a range of integers, you either have to implement it
> as a template or use any_iterator/any_range which could be too inefficient.
The other alternative is to use the boost::filesystem::path/N3336
approach, which avoids conversion inefficiency if no conversion is
necessary, but does come at the cost of creating a temporary when a
conversion is required.
Anyhow, that's all an aside to the real questions: What are the pros
and cons of N3334 in general and basic_string_ref in particular?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk