opDispatch and UFCS

cal callumenator at gmail.com
Mon Jul 1 17:45:22 PDT 2013


import std.conv, std.stdio, std.algorithm;

struct S {
     void opDispatch(string s, T...)(T t) if (s.startsWith("foo")) 
{
         writeln(s);
     }
}

void main() {
     S s;
     s.foo();
     auto p = s.to!string(); // Error: s.opDispatch!("to") isn't a 
template
}

Should the constraint on opDispatch allow the UFCS "to" call on S?


More information about the Digitalmars-d-learn mailing list