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 { 18 #if _LIBCPP_STD_VER > 11 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 } 26 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); 38 upint p = std::get<0>(std::move(t)); // get rvalue 39 assert(*p == 4); 40 assert(std::get<0>(t) == nullptr); // has been moved from 41 } 42 43 #endif 44 } 45