Consider the following snippet, which attempts to recreate (a better, extensible) to:
import openmethods;
mixin(registerMethods);
interface BaseWrapper { }
class Wrapper(T): BaseWrapper
{
T value;
this(T v) { value = v; }
}
T
to(T)(virtual!BaseWrapper);
@method
Wrapper!T
_to(T)(Wrapper!string w)
{
import std.conv;
return new Wrapper!T(std.conv.to!T(w.value));
}
void
main()
{
updateMethods;
auto s = new Wrapper!string("12");
assert(s.to!int == 12);
}
This doesn't compile because, it seems, the open methods mechanism doesn't kick in for to and the compiler doesn't see Wrapper!string as a possible stand-in for virtual!BaseWrapper. The error message is
function app.to!int.to (virtual!(BaseWrapper)) is not callable using argument types (Wrapper!string)
Is it possible to enable the library to work with templates? This would add a considerable layer of cool and useful to it.
Consider the following snippet, which attempts to recreate (a better, extensible)
to:This doesn't compile because, it seems, the open methods mechanism doesn't kick in for
toand the compiler doesn't seeWrapper!stringas a possible stand-in forvirtual!BaseWrapper. The error message isIs it possible to enable the library to work with templates? This would add a considerable layer of cool and useful to it.