Constrain your user-defined conversions -- Jonathan Mueller
Sometimes you want to add an implicit conversion to a type. This can be done by adding an implicit conversion operator. For example, std::string is implicitly convertible to std::string_view.
Constrain Your User-Defined Conversions
By Jonathan Mueller
From the article:
Sometimes you want to add an implicit conversion to a type. This can be done by adding an implicit conversion operator. For example,
std::stringis implicitly convertible tostd::string_view:class string { // template omitted for simplicity public: operator std::string_view() const noexcept { return std::string_view(c_str(), size()); } };The conversion is safe, cheap, and
std::stringandstd::string_viewrepresent the same platonic value — we match Tony van Eerd’s criteria for implicit conversions and using implicit conversions is justified.However, even when all criteria are fulfilled, the conversion can still be dangerous.

In my last post "Monitor Object" I implemented a thread-safe queue. I made two serious errors. Sorry. Today, I will fix these issues.
Registration is now open for CppCon 2023! The conference starts on October 1 and will be held
This article goes over the spicy topic of object ownership. We covered the lifetime quirks, and we found out that manual memory management can be a nightmare, we
Registration is now open for CppCon 2023! The conference starts on October 1 and will be held 
Visual Studio 17.6 comes with new functionality in the Address Sanitizer runtime which provides a new “checked build” for C and C++. This new runtime mode diagnoses and reports hidden memory safety errors, with zero false positives, as your app runs.
Registration is now open for CppCon 2023! The conference starts on October 1 and will be held
Registration is now open for CppCon 2023! The conference starts on October 1 and will be held