Mixin template function

cal callumenator at gmail.com
Wed Feb 13 16:29:50 PST 2013


Should the following work?

import std.traits;

mixin template Foo()
{
     void foo(T)(T t) if (isSomeString!T) {}
}

class A
{
     void foo()(int i){}
     mixin Foo;
}

void main()
{
     auto a = new A;
     a.foo("hello");
}

Error: template hello.A.foo does not match any function template 
declaration. Candidates are:
hello.A.foo()(int i)

If i give the mixin an identifier (mixin Foo _foo) and call it 
like a._foo.foo("hello") then it works. I thought it should work 
without that though.


More information about the Digitalmars-d-learn mailing list