SSO enables short strings to be stored on stack. What if I have a std::map<std::string, std::string>
(or any std container for that matter) which consists mainly of short strings (1 to 10 characters), and it grows to a big size (let's say 200,000 pairs). With average length of 5, this will take up around 2 MB on characters alone, which is more than enough to cause stack overflow if SSO will work for all the strings.
So the question is: how likely is the stack overflow? How exactly SSO will work in that case (MinGW 6.0, C++14, Windows 10 x64 machine)?
std::map
allocated its node.vector
andmap
where the elements are on the heap.std::string
. It's own static size is what controls how many character it can support using SSO.struct S { char foo[20]; };
--S *pS = new S;
-- Is thefoo
array inpS
on the stack or heap?