#include <type_traits>
//template<typename T>
//concept EnumClass = is_scoped_enum<T>::value; // implementation as seen https://en.cppreference.com/w/cpp/types/is_scoped_enum
template<typename T>
concept EnumClass = std::is_enum_v<T>; // for testing locally
enum class A { a };
enum class B { b };
template <EnumClass ECA, EnumClass ECB>
class Bar
{
public:
template<ECA ECAval, ECB ECBval>
void Foo() {}
};
class Deriving :
public Bar<A, B>
{
public:
void Foo()
{
// you can reuse "base implementation" here if needed
Bar<A, B>::Foo<A::a, B::b>();
/* impl... */
}
};
int main()
{
}
2条答案
按热度按时间2q5ifsrm1#
为什么不这样做呢?
6vl6ewon2#
我建议使用标记调度来重载,而不是专门化:
不使用
Derived
...