I had this code working in VS2012 Nov CTP:
//.h
template<template <typename...> class Container>
class Test {
typedef Container<unsigned int, TestEntry> L1;
Test();
...
}
//.cpp
template<template <typename...> class Container>
Test<Container>::Test() {}
...
template class Test<std::map>;
template class Test<std::unordered_map>;
//main.cpp
#include "test.h"
#include <map>
#include <unordered_map>
int main()
{
Test<std::map> test;
std::cout << "COMPILES!!!" << std::endl;
return 0;
}
I just updated to Visual Studio 2013 Ultimate and it will not compile, with the error:
'std::map' : too few template arguments
I know that I can relax the template requirements with something like:
template< typename MapType>
But this is not a good solution for me, as the only thing that I want to customize is the container type, not the contents. Also the contents are complex and would be a problem to have to write each time.
Is there a way to solve this in VS2013? I have been trying to fix it for hours with no luck.
Update:
To reproduce exactly in VS2013:
//test.h
#include <map>
#include <unordered_map>
template<template <typename...> class Container>
class Test {
typedef Container<unsigned int, unsigned int> L1;
};
//test.cpp
#include "test.h"
template<> class Test<std::map> {
public:
typedef std::map<unsigned int, unsigned int> L1;
};
template<> class Test<std::unordered_map> {
public:
typedef std::unordered_map<unsigned int, unsigned int> L1;
};
//main.cpp
#include "test.h"
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
int main()
{
Test<std::map> test3;
std::cout << "COMPILES!!!" << std::endl;
return 0;
}