byRef in std.range.Retro

Andrej Mitrovic none at none.none
Wed Dec 29 09:51:59 PST 2010


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!


More information about the Digitalmars-d-learn mailing list