3 ms·
> Static casts can call several conversion constructors Feel free to play with it some more: https://godbolt.org/z/7fGnj6db1 https://godbolt.org/z/7fGnj6db1
by MauranKilom 5y ago
> Static casts can call several conversion constructors
Feel free to play with it some more:
https://godbolt.org/z/7fGnj6db1 https://godbolt.org/z/7fGnj6db1
It consists of two user-defined conversions in the argument and one user-defined conversion (i.e. converting constructor) in the initialization. The reason for that is: https://timsong-cpp.github.io/cppwp/n4659/over.match.conv#1.1 https://timsong-cpp.github.io/cppwp/n4659/over.match.conv#1....
Hence, the following can actually do four conversion:
Foo foo;
Bar4 barfoo{static_cast<Bar2>(foo)};