I am playing with template specializations to learn their limits, and I was trying now not to specialize based on type, but using an integer parameter. But I am failing.
For instance, a template template <class T>
should be specialized to have T
for instance a string, but having an additional template parameter as template <int I>
.
What does the standard say, and how can I do (if it can be done)? My code follows.
Thanks!
#include <iostream>
#include <typeinfo>
#include <tuple>
#include <string>
template <class T, class... U>
class many
{
public:
T t;
std::tuple<U...> u;
};
template <int size>
class many<int>
{
// ???
};
int main(int argc, char* argv[])
{
many<int, std::string, char> m;
m.t = -1;
std::get<0>(m.u) = "hello";
std::get<1>(m.u) = 'w';
std::cout << "many: " << std::endl;
std::cout << m.t << std::endl;
std::cout << std::get<0>(m.u) << std::endl;
std::cout << std::get<1>(m.u) << std::endl;
return 0;
}