考虑下面的代码:
template<typename...>
struct C
{ /* ... */ };
template<typename T, unsigned N>
struct B
{
using type = /* ... */;
};
template<size_t N, typename... Ts>
struct A
{
using type = C<typename B<Ts, N-->::type...>; // decrement N sizeof...(Ts) times
};
因此举个例子:
typename A<5, int, long, void>::type
扩展到
C<typename B<int, 5>::type, typename B<long, 4>::type, typename B<void, 3>::type>
由于N
是一个const
值,所以此代码无法编译。有其他的方法吗?
5--
一样,毫无意义。 - Nicol BolasN-1
有什么问题吗? - 463035818_is_not_a_number