blob: 176d58330d16567d21bd7b88847d567b160d8c60 [file] [log] [blame]
Marshall Clowe8029e52013-07-13 02:54:05 +00001//===----------------------------------------------------------------------===//
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
16int main()
17{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070018#if _LIBCPP_STD_VER > 11
Marshall Clowe8029e52013-07-13 02:54:05 +000019 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 Albert1d4a1ed2016-05-25 22:36:09 -070026
Marshall Clowe8029e52013-07-13 02:54:05 +000027 {
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 Albert1d4a1ed2016-05-25 22:36:09 -070038 upint p = std::get<0>(std::move(t)); // get rvalue
Marshall Clowe8029e52013-07-13 02:54:05 +000039 assert(*p == 4);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070040 assert(std::get<0>(t) == nullptr); // has been moved from
Marshall Clowe8029e52013-07-13 02:54:05 +000041 }
42
Dan Albert1d4a1ed2016-05-25 22:36:09 -070043#endif
Marshall Clowe8029e52013-07-13 02:54:05 +000044}