new properties for basic types
Dominikus Dittes Scherkl via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 14 05:19:28 PDT 2014
On Monday, 14 July 2014 at 11:28:15 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:
> Halas, that's not what the OP wants. He needs properties on the
> *type*
> itself: int.foo instead of foo!int.
Yes, exactly.
>
> So no, this is not possible.
Hmm.
So how do I use stuff like this:
template defaultInit(T)
{
static if (!is(typeof({ T v = void; }))) // inout(U)
@property T defaultInit(T v = T.init);
else
@property T defaultInit();
}
(this is from std.traits - ok, it's private, but anyway)
Because I have seen nowhere anything like defaultInit!T (or
T.defaultInit)
and don't understand why here the attribute @property is used.
Why does it make a difference, and how?
More information about the Digitalmars-d-learn
mailing list