C++ Logo

std-discussion

Advanced search

Re: extremely long compile time with large number of string literals

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 18 Jul 2020 10:30:29 -0700
On Saturday, 18 July 2020 09:44:02 PDT Mandeep Sandhu wrote:
> > Ideally a constexpr string object using constexpr operator new could do
> > that, but such a thing does not exist in C++ yet and definitely did not
> > for C++11 or C++14.
> >
> > The best you can get until is to benefit from the Small String
> > Optimisation.
> What is the size threshold at which SSO kicks in? Is it implementation
> defined? Is there a way to figure out if a string has been "SSO-ed" ?

It's implementation defined. You can tell that it has kicked in when
str.c_str() points to inside of str. But don't try to determine that, just
write code without assuming where std::string stores data.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2020-07-18 12:33:50