C++ Template Specialization with Constant Value
问题 Is there a straightforward way for defining a partial specialization of a C++ template class given a numerical constant for one of the template parameters? I'm trying to create special constructors for only certain kinds of template combinations: template <typename A, size_t B> class Example { public: Example() { }; A value[B]; }; template <typename A, 2> class Example { public: Example(b1, b2) { value[0] = b1; value[1] = b2; }; }; This example won't compile, returning an error Expected