struct S
{
        int a;
        this(T)(T v)
        {
                this = v;
        }
        void foo(T)(T v)
        {
                import std.conv : to;
                a = v.to!int;
        }
        alias foo this;
}

void bar(S s){}

void main()
{
        S s0;
        s0 = "3"; //OK
        S s = "3"; //OK
        bar("3"); //Not OK
}

It would seem logical that the last one would work as well. What's the reasoning behind this?

Reply via email to