How can I induce implicit type convesion with alias this on calling template function?
Sobaya
sobaya007 at gmail.com
Mon Oct 15 04:51:39 UTC 2018
void func(T : int)(T value) if (is(T == int)) {
}
struct S {
int x;
alias x this;
}
void main() {
func(S()); // error
}
In above code, 'func' can accept only int as its argument type,
so when 'S', which can be implicitly convertible into int, is
passed on 'func', I expect S.x is passed, but this function call
is failed.
Is there any way to solve it with keeping 'func' template
function?
More information about the Digitalmars-d-learn
mailing list