Created
June 3, 2015 06:19
-
-
Save RicherMans/0cb2c28c5d1098a1b5b4 to your computer and use it in GitHub Desktop.
Variadic Templates
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
| template <typename... Ts> class Tuple{}; | |
| template <typename T,typename... Ts> class Tuple<T, Ts...>:Tuple<Ts...>{ | |
| public: | |
| Tuple(T t,Ts... args):Tuple<Ts...>(args...),curt(t){}; | |
| private: | |
| T curt; | |
| }; | |
| template <size_t k, typename T, typename... Ts> | |
| class Holder<k, Tuple<T, Ts...>>{}; | |
| template <size_t k, typename T, typename... Ts> | |
| class Holder<k, Tuple<T, Ts...>> { | |
| typedef typename Holder<k - 1, Tuple<Ts...>>::type type; | |
| }; | |
| template <typename T,typename... Ts > class Holder<0, Tuple<T, Ts...>> { | |
| typedef T type; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment