In the following code, I'm taking address to static constexpr member:
struct component_type_data{}; template<class Derived> class component{ private: const constexpr static component_type_data type_data{}; public: static constexpr const component_type_data* component_type = &type_data; }; My motivation is to have compile time unique id for type.
Is this valid? Code compiles only starting from C++17. And I can use that pointer as template argument.
If this valid, how compiler can know address beforehand?
UPDATE. :
Also, what happens across dll boundaries? Each dll will have its own unique address for the same static member, or they will be the same?