18 lines · cpp
1 2template <typename T>3constexpr T my_pi = T(3.1415926535897932385L); // variable template4 5template <> constexpr char my_pi<char> = '3'; // variable template specialization6 7template <typename T>8struct Wrapper {9 template <typename U> static constexpr U my_const = U(1);10 // Variable template partial specialization with member variable.11 template <typename U> static constexpr U *my_const<const U *> = (U *)(0);12};13 14constexpr char a[] = "hello";15 16template <> template <>17constexpr const char *Wrapper<float>::my_const<const char *> = a;18