I know that in C++98, neither std::basic_string<>
nor std::vector<>
were required to use contiguous storage. This was seen as an oversight for std::vector<>
as soon as it was pointed out, and, if I remember correctly, got fixed with C++03.
I seem to remember having read about discussions requiring std::basic_string<>
to use contiguous storage back when C++11 was still called C++0x, but I haven't followed the discussion closely back then, and am still restricted to C++03 at work, so I am not sure what became of it.
So is std::basic_string<>
required to use contiguous storage? (If so, then which version of the standard required it first?)
In case you wonder: This is important if you have code passing the result of &str[0]
to a function expecting a contiguous piece of memory to write to. (I know about str.data()
, but for obvious reasons old code doesn't use it.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…