Created
March 31, 2016 02:54
-
-
Save amidvidy/f5505a0b24f91684289f74975731192d to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
#include <string> | |
#include <vector> | |
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