"the last change" for ranges

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed May 20 21:39:36 PDT 2009


Nick Sabalausky wrote:
> "Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
> news:gv2hj8$k1n$1 at digitalmars.com...
>> dsimcha wrote:
>>
>> Consider:
>>
>> struct R
>> {
>>     bool empty();
>>     ref int front();
>>     void popFront();
>> }
>>
>> ref int popNext(ref R fwdRange)
>> {
>>     auto result = & fwdRange.front();
>>     fwdRange.popFront;
>>     return *result;
>> }
>>
>> void main()
>> {
>>     R r;
>>     int x = r.popNext;
>> }
>>
>> This should work, I just noticed with surprise it doesn't. It's a bug, 
>> specifically bug 3015:
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=3015
>>
> 
> I thought that was only supposed to work for arrays. Has that changed? If 
> so, what's the new rule?

If a.fun(args) doesn't find fun, rewrite to fun(a, args).

Andrei



More information about the Digitalmars-d mailing list