It is more a curse than a blessing to me, there are really few relevant cases where an implicit case can be considered, most of the time, it’s not. std::string::string(char const*) is typically a case where the implicit constructor hide a whole copy of the string and a potential heap allocation.
Implicit things should be trivial, non-trivial things should be explicit.
Yes C++ has always allowed implicit "casting" of values. If a suitable constructor has been found.
That is both a blessing and a curse.
Of course it's up to you to design in what your class should or should not have.
It is more a curse than a blessing to me, there are really few relevant cases where an implicit case can be considered, most of the time, it’s not. std::string::string(char const*) is typically a case where the implicit constructor hide a whole copy of the string and a potential heap allocation.
Implicit things should be trivial, non-trivial things should be explicit.
Yes, and most static analyzers advise you to add explicit keyword to constructors
Yeah.. C++ can be like that.
Effective C++ covers all these odd cases. The book could also have been called "50 ways C++ can have hidden memory leaks".