www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - byRef in std.range.Retro

Is it a common Phobos idiom to add this to all range functions?:

enum bool byRef = is(typeof(&(R.init.front())));

It's defined in std.range.Retro, but it isn't used there. So I'm wondering if
it's an artifact leftover from a previous implementation, or if it is there
"just in case", since other range functions have a byRef member too.

I think I understand the purpose of byRef, this determines at compile time if
the returned Range will have functions that return by reference or not and take
other types by reference or not.

I didn't even know you can add a storage class as part of an alias:
alias ref .ElementType!(R) ElementType;

That's pretty cool!
Dec 29 2010