C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: extremely long compile time with large number of string literals
From: Thiago Macieira (thiago_at_[hidden])
Date: 2020-07-13 12:19:21


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

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups