Я играл с вариативными шаблонами и заметил следующее.
Это отлично работает:
auto t = std::make_tuple(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
Это даст ошибку ( gcc 4.8.2 (править: Clang 3.4) имеет максимальную глубину 256 по умолчанию):
auto t2 = std::make_tuple(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
Однако создание набора напрямую будет работать:
std::tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> t3(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
Я заметил это, пытаясь создать шаблонную функцию, которая возвращает шаблонный класс.
template <typename...Arguments>
struct Testing {
std::tuple<Arguments...> t;
Testing(Arguments...args) : t(args...) {}
};
template <typename... Arguments>
Testing<Arguments...> create(Arguments... args) {
return Testing<Arguments...>(args...);
}
В этом случае это будет работать:
auto t4 = create(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
и это не будет:
auto t5 = create(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);