Conveniently Declaring Compile-Time Strings in C++

I haven’t seen anything to match the elegance of Scott Schurr’s str_const presented at C++ Now 2012. It does require constexpr though. Here’s how you can use it, and what it can do: int main() { constexpr str_const my_string = “Hello, world!”; static_assert(my_string.size() == 13, “”); static_assert(my_string[4] == ‘o’, “”); constexpr str_const my_other_string = my_string; … Read more