References to const
Steven Schveighoffer
schveiguy at yahoo.com
Thu Nov 13 06:26:25 PST 2008
"Andrei Alexandrescu" wrote
>> Is there a way to have variable reference to constant data in D? I
>> just don't see it at the moment and it would be _really_ useful.
>
> http://www.digitalmars.com/d/2.0/phobos/std_typecons.html#Rebindable
Small question regarding Rebindable that I've been meaning to ask.
Does implicit assignment to a const(T) work, or does that require
opImplicitCast? This would be useful not only for assignment, but also
passing to functions which take const(T) instead of Rebindable!(T).
Also, one other thing. A Rebindable!(T) only makes sense if T is const or
invariant, but this is rather long winded:
Rebindable!(const(A)) a;
Would it make sense to have shortcuts to Rebindable that automatically apply
const or invariant? something like:
template tconst(T)
{
alias Rebindable!(const(T)) tconst;
}
Using whatever you think is best for a symbol name. Just something a little
shorter.
-Steve
More information about the Digitalmars-d
mailing list