For silly reasons I\'ll not go into here, I need the commented out line to work and the line above it it to not work:
template
Here's a solution: Instead of truncating N
from the back, I just truncate sizeof...(Args) - N
from the front:
#include
/* Concatenator helper */
template struct cat;
template
struct cat>
{
typedef typename std::tuple value;
};
/* Head-of-tuple */
template struct tuple_head;
// Base case. Need to specialize twice, once for one and once for variadic types
template
struct tuple_head<0, Args...>
{
typedef std::tuple<> value;
};
template
struct tuple_head<0, T>
{
typedef std::tuple<> value;
};
// Recursion step
template
struct tuple_head
{
typedef typename cat::value>::value value;
};
/* User interface */
template
struct PartialTuple
{
typedef typename tuple_head::value type;
};
/* Usage */
#include
int main()
{
// I want this to not work...
//PartialTuple<1, std::string, std::string, int, int>::type A{"test", 5, 1};
// I want this to work...
PartialTuple<1, std::string, std::string, int, int>::type B("test", "test", 5);
PartialTuple<0, std::string, std::string, int, int>::type C("test", "test", 5, 6);
}