MCVE神栓链接
我有一个概念Trait_AActuallyBTemplate<A,B>
来检查是否A
= B<...something...>
。
它有效。
如何创建一个新概念来检查是否A
继承B<...something...>
?
#include <vector>
#include <iostream>
namespace hid{
template <typename T,template<typename... Ty> typename B>
struct is_mytype : std::false_type { };
template <typename... A,template<typename... Ty> typename B>
struct is_mytype<B<A...> ,B> : std::true_type { };
};
template <typename T,template<typename... Ty> typename B>
concept Trait_AActuallyBTemplate = hid::is_mytype<T,B>::value;
//vvv please modify here
template <typename T,template<typename... Ty> typename B>
concept Trait_AInheritFromBTemplate = hid::is_mytype<T,B>::value;
//^^^ please modify here
int main() {
static_assert(Trait_AActuallyBTemplate<std::vector<int>,std::vector>,"hehe1");
static_assert(!Trait_AActuallyBTemplate<int,std::vector>,"hehe2");
struct MyVector : public std::vector<int> {};
static_assert(Trait_AInheritFromBTemplate<MyVector,std::vector>,"hehe3");
//^^^ Assert fail only here. (It should pass) I am sad.
}