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 // <tuple> 11 12 // template <class... Types> class tuple; 13 14 // template <class... Types> 15 // class tuple_size<tuple<Types...>> 16 // : public integral_constant<size_t, sizeof...(Types)> { }; 17 18 // XFAIL: gcc-4.9 19 // UNSUPPORTED: c++98, c++03 20 21 #include <tuple> 22 #include <array> 23 #include <type_traits> 24 25 template <class T, size_t Size = sizeof(std::tuple_size<T>)> 26 constexpr bool is_complete(int) { static_assert(Size > 0, ""); return true; } 27 template <class> constexpr bool is_complete(long) { return false; } 28 template <class T> constexpr bool is_complete() { return is_complete<T>(0); } 29 30 struct Dummy1 {}; 31 struct Dummy2 {}; 32 33 namespace std { 34 template <> class tuple_size<Dummy1> : public integral_constant<size_t, 0> {}; 35 } 36 37 template <class T> 38 void test_complete() { 39 static_assert(is_complete<T>(), ""); 40 static_assert(is_complete<const T>(), ""); 41 static_assert(is_complete<volatile T>(), ""); 42 static_assert(is_complete<const volatile T>(), ""); 43 } 44 45 template <class T> 46 void test_incomplete() { 47 static_assert(!is_complete<T>(), ""); 48 static_assert(!is_complete<const T>(), ""); 49 static_assert(!is_complete<volatile T>(), ""); 50 static_assert(!is_complete<const volatile T>(), ""); 51 } 52 53 54 int main() 55 { 56 test_complete<std::tuple<> >(); 57 test_complete<std::tuple<int&> >(); 58 test_complete<std::tuple<int&&, int&, void*>>(); 59 test_complete<std::pair<int, long> >(); 60 test_complete<std::array<int, 5> >(); 61 test_complete<Dummy1>(); 62 63 test_incomplete<void>(); 64 test_incomplete<int>(); 65 test_incomplete<std::tuple<int>&>(); 66 test_incomplete<Dummy2>(); 67 } 68