confused about template constructors and implicit type conversions
NeeO
zelux at gmx.us
Wed Dec 4 23:53:53 UTC 2019
Would someone be able to explain this ? I can only seem to call a
template constructor in one way, but I can't seem to pass what
looks like an accepted type to the template constructor via a
function call.
/+ main.d +/
import std.stdio ;
struct obj_ (T) {
int demo ;
this (int R,int C)(T[R][C] val) {
writeln ("init for type is ",val.init) ;
writeln ("num rows ",R ) ;
writeln ("num cols ",C ) ;
}
}
void check (obj_!float val) {
writeln ("success") ;
}
int main () {
float[3][4] testval ;
obj_!float p = testval ; /+ works +/
check (testval) ; /+ not callable using argument types
compiler error +/
return 0 ;
}
More information about the Digitalmars-d-learn
mailing list