On Fri, Nov 06, 2020 at 03:36:46PM +, Paul Backus via Digitalmars-d-learn
wrote:
[...]
> User-defined implicit conversions are one of the most error-prone
> features of C++, and have been deliberately excluded from D, with the
> exception of `alias this`.
And Walter is already expressing regr
On Friday, 6 November 2020 at 15:01:21 UTC, Andrey Zherikov wrote:
But how can I achieve the same result if S1 is a template
"struct S1(T) {}" and S2 should be convertible to S1!T with any
T?
Also why neither "opCast"
struct S2 { S1 opCast(T)() const if(is(T == S1)) { return
S1(); } }
There is a way to implicitly convert non-template user type, for
example:
struct S2
{
@property S1 s1() { return S1(); }
alias s1 this;
}
struct S1 {}
S1 f() { return S2(); } // implicit conversion from S2 to S1
But how can I achieve the same