1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <type_traits>
#include <iostream>
#include <vector>
#include <set>
template<class T, class U>
struct is_same_base : std::is_same<T,U>
{};
template<
template <class... BaseArgs> class BaseClass,
class... LeftArgs,
class... RightArgs
>
struct is_same_base <BaseClass<LeftArgs...>, BaseClass<RightArgs...> > : std::true_type
{};
int main()
{
std::cout << is_same_base<std::vector<int>, float >::value << std::endl; // false
std::cout << is_same_base<std::vector<int>, std::vector<int> >::value << std::endl; // true
std::cout << is_same_base<std::set<int>, std::vector<int> >::value << std::endl; // false
std::cout << is_same_base<std::vector<int>, std::vector<float> >::value << std::endl; // true
return 0;
} |
Partager