Strings in C++
Basic Strings
class std::string
{
char* buf;
size_t len;
size_t allocated_len;
};Small Object Optimization
class std::string
{
char* buf;
size_t len;
// union is used to store different data types in the same memory location
// this saves space in case only one of them is necessary
union
{
size_t allocated_len;
char local_buf[8];
};
};Last updated
Was this helpful?