r/cpp • • Dec 07 '22

C++ overtakes Java in language popularity index

https://www.infoworld.com/article/3682141/c-plus-plus-overtakes-java-in-language-popularity-index.html
382 Upvotes

137 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Dec 08 '22

An optional and a default usable value aren't exactly the same. For example, a string object's default can be a short string optimization containing "" (empty string). It contains a length of 0 and an existing value.

But of course, my idea isn't a silver bullet. std::optional might have overhead, but it gives a clearer idea of possible object states.