Skip to content

Instantly share code, notes, and snippets.

@Angeart
Created May 22, 2018 08:55
Show Gist options
  • Select an option

  • Save Angeart/e35589c802b95c20cf79768ac21ff7f8 to your computer and use it in GitHub Desktop.

Select an option

Save Angeart/e35589c802b95c20cf79768ac21ff7f8 to your computer and use it in GitHub Desktop.
inherit class for meta programming
#pragma once
#include <type_traits>
namespace util {
template<class... T>
struct inherit{
template<class...Args>
inherit(Args&&...){};
};
template<class T>
struct inherit<T> : T{
template<class...Args>
inherit(Args&&...args) : T(std::forward<Args>(args)...){};
};
template<class H, class... T>
struct inherit<H,T...> : H, inherit<T...> {
template<class...Args>
inherit(Args&&... args) : H(args...), inherit<T...>(std::forward<Args>(args)...){};
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment