Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 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 | #include <utility> |
| 11 | #include <string> |
| 12 | #include <complex> |
| 13 | |
| 14 | #include <cassert> |
| 15 | |
| 16 | int main() |
| 17 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 18 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 19 | typedef std::complex<float> cf; |
| 20 | { |
| 21 | auto t1 = std::make_pair<int, cf> ( 42, { 1,2 } ); |
| 22 | assert ( std::get<int>(t1) == 42 ); |
| 23 | assert ( std::get<cf>(t1).real() == 1 ); |
| 24 | assert ( std::get<cf>(t1).imag() == 2 ); |
| 25 | } |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 26 | |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 27 | { |
| 28 | const std::pair<int, const int> p1 { 1, 2 }; |
| 29 | const int &i1 = std::get<int>(p1); |
| 30 | const int &i2 = std::get<const int>(p1); |
| 31 | assert ( i1 == 1 ); |
| 32 | assert ( i2 == 2 ); |
| 33 | } |
| 34 | |
| 35 | { |
| 36 | typedef std::unique_ptr<int> upint; |
| 37 | std::pair<upint, int> t(upint(new int(4)), 42); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 38 | upint p = std::get<0>(std::move(t)); // get rvalue |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 39 | assert(*p == 4); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 40 | assert(std::get<0>(t) == nullptr); // has been moved from |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 43 | #endif |
Marshall Clow | e8029e5 | 2013-07-13 02:54:05 +0000 | [diff] [blame] | 44 | } |