Category : uniform-initialization

Consider the following snippet: #include <string> #include <string_view> int main() { auto str = std::string{}; auto sv1 = std::string_view(str + "!"); // <- warning 🙂 std::string_view sv2(str + "!"); // <- warning 🙂 std::string_view sv3 = str + "!"; // <- warning 🙂 auto sv4 = std::string_view{str + "!"}; // <- no warning 🙁 std::string_view ..

Read more

Recently, I came across code like this: class NeedsFactoryForPublicCreation { private: struct Accessor { // Enable in order to make the compile failing (expected behavior) // explicit Accessor() = default; }; public: explicit NeedsFactoryForPublicCreation(Accessor) {} // This was intended to be the only public construction way static NeedsFactoryForPublicCreation create() { NeedsFactoryForPublicCreation result{Accessor()}; // … Do ..

Read more