Created
March 31, 2016 02:55
-
-
Save amidvidy/65b31f9797f3eac49d002c46e24c6aeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Base1 { | |
public: | |
void foo() { | |
std::cout << "Base1" << std::endl; | |
} | |
}; | |
class Base2 { | |
public: | |
void foo() { | |
std::cout << "Base2" << std::endl; | |
} | |
}; | |
template <typename... Bases> | |
class Derived : public Bases... { | |
}; | |
template<typename... Bases> | |
void call_foo_on_bases(Derived<Bases...> derived) { | |
using expander = int[]; | |
(void) expander {0, (derived.Bases::foo(), 0)...}; | |
} | |
int main() { | |
call_foo_on_bases(Derived<Base1, Base2>()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment