ARTICLE AD BOX
There is no best solution. The intuitive way is std::string_view. I always recommend using std::literals, because then you can simply write: auto str="str"sz; with deferred type deduction. If the constants are organized as an array:
using std::literals; constexpr static std::array str_arr { "str 0"sv, "str 1"sv, "str 2"sv };Depending on the code and compiler this may increase your binary size by a few bytes. If that matters, then you need to define a string_list class of your own, with constexpr constructor, and desired properties.
std::string may be more efficient iff the string constants are short(less than 16 bytes in size). But there's unfortunately no std function that tells the short string maximum size. But if you can confirm the shortness criteria, then UDLs make code simpler to write again:
using std::literals; constexpr static std::array str_arr { "str 0"s, "str 1"s, "str 2"sI never recommend raw character arrays as string literals in C++. Aside from the decay problems associated with all raw arrays, raw character arrays have ambiguous usage; null-terminated string vs array of character values. This ambiguity may result in unpleasant surprises. Therefore, I always encourage using UDLs; sv for string_view and s for std::string. If you need arrays, std::array is available. Don't use the ambiguous raw character array literals, unless initializing an array like: std::array{"array ends in null"}.
