给定一个模板参数,如何确定这是否实际上是一个参数化模板 class?
Given a template argument, how to find out whether or not this is actually a parameterized template class?
假设我有以下代码。
template <template <typename...> class C, typename T>
constexpr bool is_vector() {
return is_same<C<T>, vector<T>>::value;
}
template <typename Value, enable_if_t<is_vector<???>()>>
void my_function(Value &value) {
}
如何调用 is_vector
以检查 Value
是否是 std::vector class 模板的实例?
通常的方法是写另一个特征...
template<class C>
struct is_vector : std::false_type {};
template<class T, class A>
struct is_vector<std::vector<T,A>>: std::true_type {};
假设我有以下代码。
template <template <typename...> class C, typename T>
constexpr bool is_vector() {
return is_same<C<T>, vector<T>>::value;
}
template <typename Value, enable_if_t<is_vector<???>()>>
void my_function(Value &value) {
}
如何调用 is_vector
以检查 Value
是否是 std::vector class 模板的实例?
通常的方法是写另一个特征...
template<class C>
struct is_vector : std::false_type {};
template<class T, class A>
struct is_vector<std::vector<T,A>>: std::true_type {};