C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: extremely long compile time with large number of string literals
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2020-07-13 12:56:36


On 2020-07-13 20:19, Thiago Macieira via Std-Discussion wrote:
> 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.

Using string_view instead of string would be better yet.


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

Older Archives on Google Groups