//******************************************************** // The following code example is taken from the book // C++20 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd20.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #include "wrapper.hpp" #include #include void printStringWrapper(Wrapper) { } void printVectorWrapper(Wrapper>) { } int main() { // implicit conversion from string literal to string: std::string s1{"hello"}; std::string s2 = "hello"; // OK Wrapper ws1{"hello"}; Wrapper ws2 = "hello"; // OK printStringWrapper("hello"); // OK // NO implicit conversion from size to vector: std::vector v1{42u}; std::vector v2 = 42u; // ERROR: explicit Wrapper> wv1{42u}; Wrapper> wv2 = 4u2; // ERROR: explicit printVectorWrapper(42u); // ERROR: explicit }