specialize a template with expression parameter
c++, templates
Solution
You can't - your template takes one type parameter, always. Specializations can only be more special than that, but not different (hence the name).
Maybe you can use an auxiliary template to store value information:
template <typename T, T Val> struct ValueWrapper { };
template <typename T> struct Foo;
templaet <typename T, T Val> struct Foo<ValueWrapper<T, Val>>
{
typedef T type;
static type const value = Val;
// ...
};
Usage:
Foo<char> x;
Foo<ValueWrapper<int, 15>> y;
Problem
I have a class like this: ``` template <class T> class Foo; ``` I want to have a specialization of ``` template <> class Foo < size_t N >; ``` but that doesn't compiles for me: my main is like: ``` Foo<int> p; // OK Foo<15> p2; // fails to compile ``` What am I missing?