I think i quite understand how to use the keyword constexpr
for simple variable types, but i'm confused when it comes to pointers to values.
I would like to declare a constexpr C string literal, which will behave like
#define my_str "hello"
That means the compiler inserts the C string literal into every place where i enter this symbol, and i will be able to get its length at compile-time with sizeof.
Is it constexpr char * const my_str = "hello";
or const char * constexpr my_str = "hello";
or constexpr char my_str [] = "hello";
or something yet different?
See Question&Answers more detail:os