3 ms·
> You want strings to be semipredicates. I mean that strings should be able to have a NULL value, as I can do with C. A null value different from "emptiness"?
by thestoicattack 8y ago
> You want strings to be semipredicates. I mean that strings should be able to have a NULL value, as I can do with C.
A null value different from "emptiness"? Would you be okay with a std::string* or a std::optional<std::string>?
- jhallenworld 8y ago"since C++17", I see.. I'm curious if it uses more space than "char *" Also it's not great because I should be able to pass such a string through functions that expect std::string. A NULL string should act just like an empty string except that you can test it for NULL.
- thestoicattack 8y agoYes. std::optional<T> allocates the T in-place. Just checked compiler explorer, and on g++ 8.1, sizeof(std::string) == 32, sizeof(std::optional<std::string>) == 40. (of course sizeof(char* ) == 8)