Every new C++ article about the latest "improvements" to the language tends to confirm my belief that C++ developers are masochists. They don't seem to be interested in actually improving the language and making in better and easier at creating useful software. They even seem to laugh at the word "easy". The entire ecosystem feels like a infinite pile of new features fixing old ones, bringing new flaws in the process. Sometimes I feel like this is the case for every language, but C++ is the worst.
template <class T>
std::string serialize(const T& obj)
if constexpr (has_serialize(obj)) { // Now we can place constexpr on the 'if' directly.
return obj.serialize(); // This branch will be discarded and therefore not compiled if obj is an int.
} else {
return std::to_string(obj);branch
}
}
I don't want a language with magic. Magic is hell for software. Show me simplicity and elegance. Show me boring but powerful. Show me how I don't have to choose between value, reference, raw pointer, unique_ptr, shared_ptr, etc, to pass a damn parameter to your function. Show me boring but powerful stuff.