assign_const_pair_U_V.pass.cpp (1317B)
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> struct pair 13 14 // template<class U, class V> pair& operator=(const pair<U, V>& p); 15 16 #include <utility> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #if TEST_STD_VER >= 11 21 #include "archetypes.hpp" 22 #endif 23 24 int main() 25 { 26 { 27 typedef std::pair<int, short> P1; 28 typedef std::pair<double, long> P2; 29 P1 p1(3, static_cast<short>(4)); 30 P2 p2; 31 p2 = p1; 32 assert(p2.first == 3); 33 assert(p2.second == 4); 34 } 35 #if TEST_STD_VER >= 11 36 { 37 using C = TestTypes::TestType; 38 using P = std::pair<int, C>; 39 using T = std::pair<long, C>; 40 const T t(42, -42); 41 P p(101, 101); 42 C::reset_constructors(); 43 p = t; 44 assert(C::constructed == 0); 45 assert(C::assigned == 1); 46 assert(C::copy_assigned == 1); 47 assert(C::move_assigned == 0); 48 assert(p.first == 42); 49 assert(p.second.value == -42); 50 } 51 #endif 52 }