On 11/14/15 12:18 AM, Jakob Ovrum wrote:
On Saturday, 14 November 2015 at 04:10:59 UTC, Steven Schveighoffer wrote:
Is it me, or is this a bug?

struct Foo
{
   template opDispatch(string s) {
      // if you uncomment this, it compiles
      //void opDispatch() {}
      void opDispatch(T...)() {}
   }
}

void main()
{
   Foo f;
   f.blue!char(); // Error: no property 'blue' for type 'Foo'
}

Usually you should explicitly instantiate opDispatch to see the real
error message(s) that prevented opDispatch from being used, but in this
case I can't find a way to do that. `f.opDispatch!("blue")!char()` is
syntactically invalid, and aliasing doesn't work either: `alias t =
f.opDispatch!"blue"; t!char(); // Error: need `this` for opDispatch`. I
wonder what the real error is.


It appears that you can't directly access the eponymous member, this doesn't work:

f.opDispatch!("blue").opDispatch!(char)();

Error: no property 'opDispatch' for type 'void'

Perhaps that fact that it *works* when you have the non-template version as the first member is the bug ;)

In any case, I have used Jack Applegame's improved version, and it works beautifully!

-Steve

Reply via email to