Created
May 22, 2018 08:55
-
-
Save Angeart/e35589c802b95c20cf79768ac21ff7f8 to your computer and use it in GitHub Desktop.
inherit class for meta programming
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
| #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