I want to check if a type is instantiation of a particular template during compilation.
For example:
std::vector<int>
is instantiation ofstd::vector
std::array<int, 5>
is instantiation ofstd::array
I can make a test that works for case 1 but does not work for case 2.
#include <iostream>
#include <type_traits>
#include <string>
#include <vector>
#include <array>
#include <queue>
template<template<typename...> class, typename...>
struct is_instantiation : public std::false_type {};
template<template<typename...> class U, typename... T>
struct is_instantiation<U, U<T...>> : public std::true_type {};
int main() {
using A = std::vector<int>;
std::cout << is_instantiation<std::vector, A>::value << "\n";
std::cout << is_instantiation<std::queue, A>::value << "\n";
// std::cout << is_instantiation<std::array, A>::value << "\n";
}
How to make it work for both cases?
I tried auto, but can't make it work.