Re:Beware of strncpy and strncat
by thestoicattack on Wednesday June 06, 2018 @01:41PM
(#17249266)
Yes. 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)
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.