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