template<class> struct Printer;
// I want this to match std::vector (and similar linear containers)
template<template<class, class...> class T, class TV, class... TS>
struct Printer<T<TV, TS...>> { ... };
// I want this to match std::map (and similar map-like containers)
template<template<class, class, class...> class TM, class TK, class TV, typename... TS>
struct Printer<TM<TK, TV, TS...>> { ... }
int main()
{
// Both of these match the second specialization, which is only intended
// for std::map (and similar map-like containers)
Printer<std::vector<int>>::something();
Printer<std::map<int, float>>::something();
}
As you can see from the example, std::vector and std::map both match the second specialization. I think it's because std::vector's allocator parameter gets matched to TV, which is intended for std::map's value.
How can I match std::vector (and other linear containers) with the first specialization and std::map (and other key-value containers) with the second one?