Implicit type conversion depending on assignment

Alexander Zhirov azhirov1991 at gmail.com
Thu Mar 23 13:38:51 UTC 2023


Is it possible to convert such records inside the structure to 
the assigned type?

```d
struct MyVal
{
     string value;
     // Here it would be possible to use an alias to this, but it 
can only be used 1 time
}

auto a = MyVal("100");
auto b = MyVal("11.2");

int MyInt = a;        // Implicitly convert to target type
float myFloat = b;    // Implicitly convert to target type
```


More information about the Digitalmars-d-learn mailing list