C++ Logo

std-discussion

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 13 Jul 2020 10:19:21 -0700
On Monday, 13 July 2020 09:52:18 PDT Mandeep Sandhu via Std-Discussion wrote:
> I wonder if const string objects can point to string literals kept in
> the .rodata section without having the need to allocate for it at
> runtime (or do they already do something similar currently?).

They can't.

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.

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

Received on 2020-07-13 12:22:41