Skip to content

Instantly share code, notes, and snippets.

@amidvidy
Created March 31, 2016 02:54
Show Gist options
  • Save amidvidy/5e6334fef93a7fcfc8d0a6acc0f61f88 to your computer and use it in GitHub Desktop.
Save amidvidy/5e6334fef93a7fcfc8d0a6acc0f61f88 to your computer and use it in GitHub Desktop.
#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