Mixin template function

monarch_dodra monarchdodra at gmail.com
Wed Feb 13 23:07:37 PST 2013


On Thursday, 14 February 2013 at 00:29:51 UTC, cal wrote:
> 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.

AFAIK, this is a bug. It has *probably* already been reported, 
but you'd have to check for it.


More information about the Digitalmars-d-learn mailing list