<story><title>Just how constexpr is C++20’s std:string?</title><url>https://quuxplusone.github.io/blog/2023/09/08/constexpr-string-firewall/</url></story><parent_chain><item><author>kccqzy</author><text>I find that there&amp;#x27;s no use case for a constexpr std::string. Maybe I&amp;#x27;m just not imaginative enough. If I want a string literal constant, I use string_view which can be constexpr. If somehow I need an actual std::string object, I use a regular const not constexpr. What would be a use case that prompts the author to explore using constexpr with std::string?</text></item></parent_chain><comment><author>fooker</author><text>Generate a large number of strings and maps programmatically in compile time.&lt;p&gt;You are pretty much limited to macros and macro-like languages (llvm-tablegen) if you want to do this today.</text></comment>
<story><title>Just how constexpr is C++20’s std:string?</title><url>https://quuxplusone.github.io/blog/2023/09/08/constexpr-string-firewall/</url></story><parent_chain><item><author>kccqzy</author><text>I find that there&amp;#x27;s no use case for a constexpr std::string. Maybe I&amp;#x27;m just not imaginative enough. If I want a string literal constant, I use string_view which can be constexpr. If somehow I need an actual std::string object, I use a regular const not constexpr. What would be a use case that prompts the author to explore using constexpr with std::string?</text></item></parent_chain><comment><author>hudsonwillis</author><text>It enables users to process string at compile time. You can implement a constexpr getRFC3339DateString(int year, int month, int day) -&amp;gt; string and then construct a constexpr string list.</text></comment>