Skip to main content
-2 votes
1 answer
184 views

class string { struct long_mode { size_t size; size_t capacity; char* buffer; }; struct short_mode { uint8_t size; char buffer[23]; }; ...
Renat's user avatar
  • 5
4 votes
2 answers
525 views

I want to check if a std::string value is using the small string optimization (SSO). I am wondering if this is defined behavior: #include <string> #include <cstdint> auto is_sso(const std:...
Chris's user avatar
  • 2,980
22 votes
2 answers
8k views

Most std::string implementations (GCC included) use small string optimization. E.g. there's an answer discussing this. Today, I decided to check at what point a string in a code I compile gets moved ...
SU3's user avatar
  • 5,519
11 votes
1 answer
1k views

Facebook's fbstring_core class uses the "Small String Optimization" described in this talk wherein the storage for the class' data members -- a Char*, size and capacity -- will be repurposed to store ...
drewbarbs's user avatar
  • 355
1 vote
2 answers
298 views

I have the following class, it contains a data structure called Index, which is expensive to compute. So I am caching the index to disk and reading it in again. The index element id of template type T ...
Brutos's user avatar
  • 711
10 votes
1 answer
2k views

In the compatibility appendix of the C++11 standard, one of the change from C++03 to C++11 is described as below: C.2.11 Clause 21: strings library 21.4.1 Change: Loosen basic_string ...
goodbyeera's user avatar
  • 3,199
11 votes
1 answer
1k views

From N3290, [container.requirements.general]: The expression a.swap(b), for containers a and b of a standard container type other than array, shall exchange the values of a and b without invoking ...
Yakov Galka's user avatar
  • 72.9k
35 votes
4 answers
17k views

I know several (all?) STL implementations implement a "small string" optimization where instead of storing the usual 3 pointers for begin, end and capacity a string will store the actual character ...
BuschnicK's user avatar
  • 5,474