Many developers and library authors have been struggling with compile-time strings for quite a few years now - as the standard (library) string, std::string
, requires dynamic memory allocation, and isn't constexpr.
So we have a bunch of questions and blog posts about how to get compile-time strings right:
- Conveniently Declaring Compile-Time Strings in C++
- Concatenate compile-time strings in a template at compile time?
- C++ Compile-Time string manipulation
- (off-site) Compile-time strings with constexpr
We've now learned that not only is new
available in constexpr
code, allowing for dynamical allocation at compile-time, but, in fact, std::string
will become constexpr in C++20 (C++ standard working group meeting report by Herb Sutter).
Does that mean that for C++20-and-up code we should chuck all of those nifty compile-time string implementations and just always go with std::string
?
If not - when would we do so, and when would we stick to what's possible today (other than backwards-compatible code of course)?
Note: I'm not talking about strings whose contents is part of their type, i.e. not talking about the equivalent of std::integral_constant
; that's definitely not going to be std::string
.