Template argument deduction and default args
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 23 23:22:38 PDT 2014
"Manu via Digitalmars-d" <digitalmars-d at puremagic.com> wrote in message
news:mailman.243.1406177619.32463.digitalmars-d at puremagic.com...
> The other case I am running in to is when I have 'struct S(T)' or 'class
> C(T)', where T > can be inferred from the constructor, but it isn't.
>
> struct S(T)
> {
> this(T t)
> {
> m = t;
> }
>
> T m;
> }
Infer this:
struct S(T)
{
static if (is(T == int))
this(float x) {}
static if (is(T == float))
this(int x) {}
}
More information about the Digitalmars-d
mailing list