1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03, c++11 11 12 // <experimental/tuple> 13 14 // template <class T> constexpr size_t tuple_size_v = tuple_size<T>::value; 15 16 #include <experimental/tuple> 17 #include <utility> 18 #include <array> 19 20 namespace ex = std::experimental; 21 22 template <class Tuple, int Expect> 23 void test() 24 { 25 static_assert(ex::tuple_size_v<Tuple> == Expect, ""); 26 static_assert(ex::tuple_size_v<Tuple> == std::tuple_size<Tuple>::value, ""); 27 static_assert(ex::tuple_size_v<Tuple const> == std::tuple_size<Tuple>::value, ""); 28 static_assert(ex::tuple_size_v<Tuple volatile> == std::tuple_size<Tuple>::value, ""); 29 static_assert(ex::tuple_size_v<Tuple const volatile> == std::tuple_size<Tuple>::value, ""); 30 } 31 32 int main() 33 { 34 test<std::tuple<>, 0>(); 35 36 test<std::tuple<int>, 1>(); 37 test<std::array<int, 1>, 1>(); 38 39 test<std::tuple<int, int>, 2>(); 40 test<std::pair<int, int>, 2>(); 41 test<std::array<int, 2>, 2>(); 42 43 test<std::tuple<int, int, int>, 3>(); 44 test<std::array<int, 3>, 3>(); 45 } 46