On 03/07/14 20:22, Frustrated wrote:
> On Friday, 7 March 2014 at 09:10:45 UTC, John Colvin wrote:
>> functions introduced through mixin templates do not take part in overload 
>> resolution when an overload exists outside the mixin.
>> It's a common annoyance, I can't remember if there's a good reason for it.
> 
> 
> This seems to be the problem. The mixin thinks they are the same function so 
> it doesn't insert it.  I guess it just looks at the name rather than the 
> complete signature. Would be real nice if that wasn't the case or if one 
> could chose the behavior. I can see in some cases it being nice to have the 
> current behavior but not all(specifically talking about overloads).


You can explicitly add the function(s) to the overload set, ie
   
   mixin template some_mixin_templ() {
      void f() {}
   }

   struct S {
      mixin some_mixin_templ blah;

      void f(int) {}
      alias f =  blah.f; // add the one(s) from the mixin template
   }

or use a string mixin (which is less problematic inside a /mixin/ template):

   mixin template some_mixin_templ(string CODE="") {
      void f() {}
      mixin (CODE);
   }

   struct S {
      mixin some_mixin_templ!q{
         void f(int) {}
      };
   }

artur

Reply via email to