References to const
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Thu Nov 13 08:32:57 PST 2008
Steven Schveighoffer wrote:
> "Andrei Alexandrescu" wrote
>> Steven Schveighoffer wrote:
>>> 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.
>> Better yet (or in addition to), we could make it a function so argument
>> deduction takes care of everything.
>>
>> Rebindable!(const T) tailconst(const T r);
>> Rebindable!(immutable T) tailimmutable(const T r);
>>
>> auto w = new Widget;
>> auto w1 = tailconst(w);
>> w1 = tailconst(new Widget);
>
> These could be useful. Also, another reason for having a rebindable type is
> that you don't have to initialize it upon declaration, so having a shorter
> type for declaration would still be beneficial.
Good argument. Now, finding the right names is the eternal challenge.
TailConst!(T), TailImmutable!(T)? Other, perhaps shorter, ideas?
Andrei
More information about the Digitalmars-d
mailing list