Any word on the return-type const syntax?
Janice Caron
caron800 at googlemail.com
Sun Dec 9 00:10:26 PST 2007
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.
More information about the Digitalmars-d
mailing list