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 // <utility> 11 12 // template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); 13 14 #include <utility> 15 #include <memory> 16 #include <cassert> 17 18 int main() 19 { 20 { 21 typedef std::pair<int, short> P1; 22 P1 p1 = std::make_pair(3, 4); 23 assert(p1.first == 3); 24 assert(p1.second == 4); 25 } 26 27 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 28 { 29 typedef std::pair<std::unique_ptr<int>, short> P1; 30 P1 p1 = std::make_pair(std::unique_ptr<int>(new int(3)), 4); 31 assert(*p1.first == 3); 32 assert(p1.second == 4); 33 } 34 { 35 typedef std::pair<std::unique_ptr<int>, short> P1; 36 P1 p1 = std::make_pair(nullptr, 4); 37 assert(p1.first == nullptr); 38 assert(p1.second == 4); 39 } 40 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 41 42 #if _LIBCPP_STD_VER > 11 43 { 44 typedef std::pair<int, short> P1; 45 constexpr P1 p1 = std::make_pair(3, 4); 46 static_assert(p1.first == 3, ""); 47 static_assert(p1.second == 4, ""); 48 } 49 #endif 50 51 } 52