Casting by assigning to the right ...
Steven Schveighoffer
schveiguy at gmail.com
Tue Apr 14 06:10:33 UTC 2020
On 4/14/20 1:56 AM, Manfred Nowak wrote:
> According to the logged changes (
> https://digitalmars.com/d/2.0/changelog.html) a thought on this was
> published in 2008/03 for D2.012: `opImplicitCast', but not implemented
> since.
The feature was implemented in a way, it's called alias this:
struct S
{
int i;
alias i this;
}
auto s = S(5);
int i = s;
assert(i == 5);
Note that at this time, only one alias this is allowed per structure.
-Steve
More information about the Digitalmars-d
mailing list