Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <tuple> |
| 11 | |
| 12 | // template <class... Types> class tuple; |
| 13 | |
| 14 | // tuple(const tuple& u) = default; |
| 15 | |
| 16 | #include <tuple> |
| 17 | #include <string> |
| 18 | #include <cassert> |
| 19 | |
Marshall Clow | 75eff74 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 20 | struct Empty {}; |
| 21 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | int main() |
| 23 | { |
| 24 | { |
| 25 | typedef std::tuple<> T; |
| 26 | T t0; |
| 27 | T t = t0; |
| 28 | } |
| 29 | { |
| 30 | typedef std::tuple<int> T; |
| 31 | T t0(2); |
| 32 | T t = t0; |
| 33 | assert(std::get<0>(t) == 2); |
| 34 | } |
| 35 | { |
| 36 | typedef std::tuple<int, char> T; |
| 37 | T t0(2, 'a'); |
| 38 | T t = t0; |
| 39 | assert(std::get<0>(t) == 2); |
| 40 | assert(std::get<1>(t) == 'a'); |
| 41 | } |
| 42 | { |
| 43 | typedef std::tuple<int, char, std::string> T; |
Howard Hinnant | fa8df7d | 2012-02-15 20:13:52 +0000 | [diff] [blame] | 44 | const T t0(2, 'a', "some text"); |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | T t = t0; |
| 46 | assert(std::get<0>(t) == 2); |
| 47 | assert(std::get<1>(t) == 'a'); |
| 48 | assert(std::get<2>(t) == "some text"); |
| 49 | } |
Marshall Clow | 75eff74 | 2013-07-22 16:02:19 +0000 | [diff] [blame] | 50 | #if _LIBCPP_STD_VER > 11 |
| 51 | { |
| 52 | typedef std::tuple<int> T; |
| 53 | constexpr T t0(2); |
| 54 | constexpr T t = t0; |
| 55 | static_assert(std::get<0>(t) == 2, ""); |
| 56 | } |
| 57 | { |
| 58 | typedef std::tuple<Empty> T; |
| 59 | constexpr T t0; |
| 60 | constexpr T t = t0; |
| 61 | } |
| 62 | #endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | } |