出于愚蠢的原因,我不会在这里讨论,我需要注释掉的行才能工作,而它上面的行不能工作:
template<uint _N, typename... _Args>
struct PartialTuple;
template<uint _N, typename _Arg, typename... _Args>
struct PartialTuple<_N, _Arg, _Args...>: PartialTuple<_N-1, _Args...> {};
template<typename _Arg, typename... _Args>
struct PartialTuple<0, _Arg, _Args...>
{
typedef std::tuple<_Arg, _Args...> type;
};
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};
}
我尝试_Arg
与交换_Args...
,但这不会编译(至少在 GCC 4.6 中):
error: parameter pack argument ‘_Args ...’ must be at the end of the template argument list
如何从尾部而不是头部拉出物品?