Created
May 18, 2016 10:17
-
-
Save cschladetsch/330b7b7e95c6ec4034f1e0f9e06909a1 to your computer and use it in GitHub Desktop.
Yay! After a little while, I understand variadic templates!
This file contains 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 | |
KAI_BEGIN | |
namespace function_detail | |
{ | |
template<int N, class... Args> | |
struct AddArgType; | |
template<int N, class Head, class... Tail> | |
struct AddArgType<N, Head, Tail...> | |
{ | |
static void Add(std::vector<Type::Number> &args) | |
{ | |
args.push_back(Type::Traits<Head>::Number); | |
AddArgType<N - 1, Tail...>::Add(args); | |
} | |
}; | |
template <class Last> | |
struct AddArgType<1, Last> | |
{ | |
static void Add(std::vector<Type::Number> &args) | |
{ | |
args.push_back(Type::Traits<Last>::Number); | |
} | |
}; | |
template<> | |
struct AddArgType<0> | |
{ | |
static void Add(std::vector<Type::Number> &) { } | |
}; | |
} | |
KAI_END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment