N
none
Unless the particular std::string implementation happens to use short
string optimization (which really isn't a given), it will be horribly
inefficient and wastes memory. Even if it *does* implement short string
optimization, it will still be a lot larger than 6 bytes. std::string
doesn't protect you from out-of-bounds accesses either (except in the
debug mode of some compilers).
If you really need an operator== for it, either write it as a member of
that struct or use std::array instead.
There's an advantage to std::string over a static array only if the size
of the string could grow. (Even then you should be aware of the possible
efficiency problems.)
Hmm, not quite as simple as that. Even without going deep into the details:
std::string::size() will be faster than strlen on a static array
std::string:perator==() is faster than strcmp if length differ.
Particularly relevant since OP stated that the id vary in length.
So depending on the data and the usage, the space overhead of
std::string may be compensated by a speed improvements.
Yannick