phobos v3 will have less templates, especially conv.to -dconf
struct myint{
int i;
bool isvalid;
int to!int()=>cast(int)i;
}
import std.conv;
myint[][][string] foo;
foo.to!(int[][][string]);
A recursive hyper overloaded .to template is the best way to support this operation of nested user types; theres things to be said about simplifying the std, but its not via removing templates as a preemptive style decision.
T[] to(T[],S)(S[] array...){
T[] output;
foreach(e;array){
output~=e;
}
return output;
}
The average block of std code is about 1000x more complex then what I would write but templates are essental complexity here
Permalink
Reply