It is more of the rhetorical question (and a rant). Pre-11 every time I had to make a library which exhibited static const char* const
(as in static const char* const class_name = "ClassA";
) as class members, I knew the library could no longer be header-only – I had to provide a .cpp
file with a definition of this variable and its value.
So instead, I had to turn it into the static
function name()
, returning the pointer.
Then C++11 came, and now I can have static constexpr char[]
as my member – and I can even give it a value in my header! But I still have to provide the definition… So I am not excited at all.
Why would that be the case? If constexpr
can be evaluated by compiler at compile time, why do I need a definition of it? Why does it have to have linkage at all?