Say I have a function that has two template template parameters like:
template <template <typename...> C1, template <typename...> C2>
constexpr bool is_same_container() {
return std::is_same<C1, C2>::value;
}
is_same_container<std::vector, std::vector>();
When I compile, the compiler complains that C1
and C2
needs to be supplied with template arguments.
Is there any way to compare two class templates directly?
std::vector
should be the same thing as std::vector
. How can I find out?
Sure, just write your own trait.
template<template<class...> class C1, template<class...> class C2>
struct is_same_template : std::false_type {};
template<template<class...> class C>
struct is_same_template<C,C> : std::true_type {};