Skip to content

Instantly share code, notes, and snippets.

@cschladetsch
Created May 18, 2016 10:17
Show Gist options
  • Save cschladetsch/330b7b7e95c6ec4034f1e0f9e06909a1 to your computer and use it in GitHub Desktop.
Save cschladetsch/330b7b7e95c6ec4034f1e0f9e06909a1 to your computer and use it in GitHub Desktop.
Yay! After a little while, I understand variadic templates!
#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