Skip to content

Instantly share code, notes, and snippets.

@ChenTanyi
Created July 29, 2020 08:32
Show Gist options
  • Save ChenTanyi/276381b3667e43715f4db5be3d92550b to your computer and use it in GitHub Desktop.
Save ChenTanyi/276381b3667e43715f4db5be3d92550b to your computer and use it in GitHub Desktop.
Derived class implement multi base function with same name but different type
#include <bits/stdc++.h>
struct A1 {
virtual void a1() = 0;
};
struct A2 {
virtual void a2() = 0;
};
struct A : public A1, A2 {
void a1() {}
void a2() {}
};
template <typename T>
struct B1 {
virtual T b1() = 0;
};
template <typename T>
struct B2 {
virtual T b2() = 0;
};
template <typename T>
struct B : public B1<T>, B2<T> {
T b1() {}
T b2() {}
};
template <typename T, typename = std::enable_if_t<std::is_base_of<A1, T>::value>>
struct C1 {
virtual B1<T*>* c() = 0;
};
template <typename T, typename = std::enable_if_t<std::is_base_of<A2, T>::value>>
struct C2 {
virtual B2<T*>* c() = 0;
};
struct C : public C1<A>, C2<A> {
B<A*>* c() {}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment