Any word on the return-type const syntax?
Robert Fraser
fraserofthenight at gmail.com
Sun Dec 9 00:18:19 PST 2007
Janice Caron wrote:
> On 12/9/07, Stewart Gordon <smjg_1998 at yahoo.com> wrote:
>> I think constness template
>> parameters (defined as a special case that generates only one instantiation)
>> would be a good way to go - this would also make it possible to parameterize
>> something on the constness of more than one entity. How about
>>
>> K(T)* ptr(constness K : this)() { return a.ptr }
>
> I /like/ this! Please can we have this syntax?
>
> (Except of course, the word is "constancy", not "constness". There's
> no such word as "constness".)
>
> For functions whose input constancy is derived from a parameter other
> than "this", one could write
>
> K(T)* f(constancy K)(K(T)[] a) { return a.ptr; }
>
> This is clearly much better than using any reserved word. Plus, the
> compiler knows to generate exactly one instantiation, with exactly
> three APIs.
Agreed, I really like this idea.
More information about the Digitalmars-d
mailing list