xref: /llvm-project/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp (revision 84f0bb619507caf7c4809400138dae1da578282a)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++03, c++11
11 
12 // Make sure that we don't blow up the template instantiation recursion depth
13 // for tuples of size <= 1024.
14 
15 #include <tuple>
16 #include <cassert>
17 #include <utility>
18 
19 template <size_t... I>
20 constexpr void CreateTuple(std::index_sequence<I...>) {
21   std::tuple<decltype(I)...> tuple(I...);
22   assert(std::get<0>(tuple) == 0);
23   assert(std::get<sizeof...(I)-1>(tuple) == sizeof...(I)-1);
24 }
25 
26 constexpr bool test() {
27   CreateTuple(std::make_index_sequence<1024>{});
28   return true;
29 }
30 
31 int main(int, char**) {
32   test();
33   static_assert(test(), "");
34   return 0;
35 }
36