opDispatch and compile time parameters
Jakob Ovrum via Digitalmars-d
digitalmars-d at puremagic.com
Fri Nov 13 21:18:45 PST 2015
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'
> }
>
> -Steve
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.
More information about the Digitalmars-d
mailing list