What is the proper way to declare a constexpr constant in a source file? I'm split between two ways:
constexpr int ORDER = 1; vs
namespace { constexpr int ORDER = 1; } // unnamed namespace The reason I question the usefulness of wrapping into an unnamed namespace is because at global scope, constexpr implies static. So similar to how in header files writing
static constexpr int ORDER = 1; makes static just a repetition, I'm assuming that the same should apply in source files as well, hence internal linkage should be guaranteed for "constexpr variables declared in a source file's global scope".
Is this the case? Are there different suggestions?
constexprdefinitely requires compile-time initialization (although as-if can as usual do a lot).inlineand never an unnamed namespace orstatic.