I've got the following piece of code:
std::string header(4, char{});
assert(header.length() == 4);
I'm wondering whether my assertion shall hold valid for the most popular compilers (VisualC++, GCC, clang). If not, for which versions does it hold valid, or from which version onward does it hold valid.
I'm assuming it must hold valid, and my assumption is from this reference:
My question also arises because this is inconsistent with the traditional behavior of strlen, and char_traits::length()
Aucun commentaire:
Enregistrer un commentaire