std.conv.to

Ali Çehreli acehreli at yahoo.com
Fri Jun 17 18:40:59 UTC 2022


On 6/17/22 10:04, Salih Dincer wrote:

 > Isn't foo and bar the same thing?  I don't understand what's the
 > difference!

 >    auto foo = to!Foo("123"); //??

 >    auto bar = Foo("321");

Yes, they are the same thing.

The OP was looking for a generic way of converting any type to any other 
type as long as there is a way. (Think a function template.) std.conv.to 
can do that because it considers the constructors as well.

Ali



More information about the Digitalmars-d-learn mailing list