Template type deduced from struct ctor?
anonymous
anonymous at example.com
Thu Mar 27 12:38:21 PDT 2014
On Thursday, 27 March 2014 at 17:59:36 UTC, Dicebot wrote:
> struct S(T)
> {
> static if (is(T == int))
> {
> this(double x) { }
> }
> static if (is(T == double))
> {
> this(int x) { }
> }
> }
>
> auto s = S(42); // should it deduce T, huh, and to what?
No, it shouldn't. You're not using T as the parameter type. Just
like T can't be deduced here:
void f(T)(double x) if(is(T == int)) {}
void f(T)(int x) if(is(T == double)) {}
f(42);
More information about the Digitalmars-d
mailing list