[phobos] is*Range + Qualified Types

David Simcha dsimcha at gmail.com
Thu Aug 12 07:08:12 PDT 2010


But that's the point.  Most ranges will be usable with const + shallow 
Unqual because they keep track of the iteration state w/o any 
indirection..  Those that aren't won't pass is*Range if they're const.

On 8/12/2010 9:58 AM, Andrei Alexandrescu wrote:
> The problem is Unqual is good with arrays but does not know what to do 
> with user-defined types. For some range R, Unqual!R does not do 
> anything interesting.
>
> Andrei
>
> David Simcha wrote:
>> When const ranges are passed by value to a function, they can safely 
>> receive an implicit shallow Unqual.  In many cases this makes them 
>> ranges of const elements that is useful.
>>
>> On 8/12/2010 1:05 AM, Shin Fujishiro wrote:
>>> David Simcha<dsimcha at gmail.com>  wrote:
>>>> I'm looking to go on a major debugging spree and make std.range work
>>>> with const ranges.  For example, the following should work:
>>>>
>>>> import std.range, std.algorithm;
>>>>
>>>> void main() {
>>>>       const foo = map!"a ^^ 2"([1,2,3,4,5]);
>>>>       auto myRetro = retro(foo);
>>>> }
>>> Could you elaborate why?
>>>
>>> Ranges with const elements must be common; but what's the point of
>>> const ranges?  Const random access ranges are usable, but other const
>>> ranges seem to be useless since popFront and popBack can't be const.
>>>
>>>
>>> Shin
>>> _______________________________________________
>>> phobos mailing list
>>> phobos at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/phobos
>>>
>>
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>



More information about the phobos mailing list