3 ms·
Huh? This has nothing to do with memory failure. Imagine: class UTF8String { public: static optional<UTF8String> FromBytes(const void *buffer
by amluto 2y ago
Huh? This has nothing to do with memory failure. Imagine:
class UTF8String {
public:
static optional<UTF8String> FromBytes(const void *buffer, size_t len);
private:
UTF8String(...);
void *bytes;
size_t length;
};
UTF8String::FromBytes can fail if the input is invalid. In this particular case, it can obviously be implemented without constructing a UTF8String until it's past the point of no return. But I can imagine cases where pulling this off is awkward.