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, c++14
10
11 // <tuple>
12
13 // template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value;
14
15 #include <tuple>
16 #include <utility>
17 #include <array>
18
19 #include "test_macros.h"
20
21 template <class Tuple, int Expect>
test()22 void test()
23 {
24 static_assert(std::tuple_size_v<Tuple> == Expect, "");
25 static_assert(std::tuple_size_v<Tuple> == std::tuple_size<Tuple>::value, "");
26 static_assert(std::tuple_size_v<Tuple const> == std::tuple_size<Tuple>::value, "");
27 static_assert(std::tuple_size_v<Tuple volatile> == std::tuple_size<Tuple>::value, "");
28 static_assert(std::tuple_size_v<Tuple const volatile> == std::tuple_size<Tuple>::value, "");
29 }
30
main(int,char **)31 int main(int, char**)
32 {
33 test<std::tuple<>, 0>();
34
35 test<std::tuple<int>, 1>();
36 test<std::array<int, 1>, 1>();
37
38 test<std::tuple<int, int>, 2>();
39 test<std::pair<int, int>, 2>();
40 test<std::array<int, 2>, 2>();
41
42 test<std::tuple<int, int, int>, 3>();
43 test<std::array<int, 3>, 3>();
44
45 return 0;
46 }
47