1e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#include <vector> 2e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#include <deque> 3e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 4e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#include "mvctor_test.h" 5e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 6e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) 7e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottusing namespace std; 8e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 9e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 10e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t MovableStruct::nb_dft_construct_call = 0; 11e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t MovableStruct::nb_cpy_construct_call = 0; 12e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t MovableStruct::nb_mv_construct_call = 0; 13e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t MovableStruct::nb_assignment_call = 0; 14e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t MovableStruct::nb_destruct_call = 0; 15e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 16e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 17e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if defined (_STLP_USE_NAMESPACES) 18e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottnamespace std { 19e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 20e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott _STLP_TEMPLATE_NULL 21e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott struct __move_traits<MovableStruct> { 22e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott typedef __true_type implemented; 23e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott typedef __false_type complete; 24e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott }; 25e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if defined (_STLP_USE_NAMESPACES) 26e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 27e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 28e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 29e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 30e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottstruct CompleteMovableStruct { 31e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct() { ++nb_dft_construct_call; } 32e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct(CompleteMovableStruct const&) { ++nb_cpy_construct_call; } 33e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 34e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct(__move_source<CompleteMovableStruct>) { ++nb_mv_construct_call; } 35e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 36e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott ~CompleteMovableStruct() { ++nb_destruct_call; } 37e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 38e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct& operator = (const CompleteMovableStruct&) { 39e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott ++nb_assignment_call; 40e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott return *this; 41e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 42e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static void reset() { 43e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott nb_dft_construct_call = nb_cpy_construct_call = nb_mv_construct_call = 0; 44e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott nb_assignment_call = 0; 45e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott nb_destruct_call = 0; 46e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 47e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 48e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static size_t nb_dft_construct_call; 49e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static size_t nb_cpy_construct_call; 50e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static size_t nb_mv_construct_call; 51e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static size_t nb_assignment_call; 52e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott static size_t nb_destruct_call; 53e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 54e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //See MovableStruct 55e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott void* dummy_data[2]; 56e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott}; 57e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 58e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t CompleteMovableStruct::nb_dft_construct_call = 0; 59e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t CompleteMovableStruct::nb_cpy_construct_call = 0; 60e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t CompleteMovableStruct::nb_mv_construct_call = 0; 61e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t CompleteMovableStruct::nb_assignment_call = 0; 62e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottsize_t CompleteMovableStruct::nb_destruct_call = 0; 63e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 64e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 65e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if defined (_STLP_USE_NAMESPACES) 66e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottnamespace std { 67e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 68e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott _STLP_TEMPLATE_NULL 69e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott struct __move_traits<CompleteMovableStruct> { 70e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott typedef __true_type implemented; 71e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott typedef __true_type complete; 72e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott }; 73e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if defined (_STLP_USE_NAMESPACES) 74e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 75e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 76e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 77e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 78e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottvoid MoveConstructorTest::move_traits() 79e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ 80e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott move_traits_vec(); 81e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott move_traits_vec_complete(); 82e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott move_traits_deq(); 83e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott move_traits_deq_complete(); 84e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 85e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 86e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottvoid MoveConstructorTest::move_traits_vec() 87e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ 88e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 89e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 90e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vector<MovableStruct> vect; 91e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(MovableStruct()); 92e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(MovableStruct()); 93e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(MovableStruct()); 94e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(MovableStruct()); 95e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 96e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 4 elements 97e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 ); 98e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) 99e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if !defined (_STLP_NO_MOVE_SEMANTIC) 100e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 101e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 3 ); 102e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# else 103e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 7 ); 104e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 105e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 7 ); 106e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#elif !defined (_MSC_VER) 107e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 7 ); 108e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 7 ); 109e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 110e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 14 ); 111e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 14 ); 112e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 113e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 0 ); 114e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 115e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // Following test violate requirements to sequiences (23.1.1 Table 67) 116e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott /* 117e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.insert(vect.begin() + 2, vect.begin(), vect.end()); 118e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 8 elements 119e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 ); 120e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 8 ); 121e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 7 ); 122e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 11 ); 123e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott */ 124e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 125e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 126e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vector<MovableStruct> v2 = vect; 127e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 0 ); 128e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 129e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 0 ); 130e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 0 ); 131e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 0 ); 132e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 133e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 134e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.insert(vect.begin() + 2, v2.begin(), v2.end() ); 135e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 136e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 8 elements 137e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 0 ); 138e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 139e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 140e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 4 ); 141e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 142e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 8 ); 143e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 144e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 0 ); 145e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 4 ); 146e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 147e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 148e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.begin(), vect.begin() + 2 ); 149e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 150e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 6 elements 151e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 152e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 6 ); 153e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 8 ); 154e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 155e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT_EQUAL( MovableStruct::nb_assignment_call, 6 ); 156e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 2 ); 157e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 158e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 159e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 160e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.end() - 2, vect.end()); 161e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 162e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 4 elements 163e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 0 ); 164e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 2 ); 165e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 166e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 167e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.begin()); 168e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 169e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 3 elements 170e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 171e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 3 ); 172e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 4 ); 173e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 174e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 3 ); 175e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 1 ); 176e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 177e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 178e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 179e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 180e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //vect with 3 elements and v2 with 4 elements are now out of scope 181e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 3 + 4 ); 182e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 183e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 184e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 185e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottvoid MoveConstructorTest::move_traits_vec_complete() 186e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ 187e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 188e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 189e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vector<CompleteMovableStruct> vect; 190e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(CompleteMovableStruct()); 191e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(CompleteMovableStruct()); 192e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(CompleteMovableStruct()); 193e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.push_back(CompleteMovableStruct()); 194e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 195e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 4 elements 196e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 ); 197e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) 198e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# if !defined (_STLP_NO_MOVE_SEMANTIC) 199e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 200e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 3 ); 201e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 ); 202e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# else 203e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 7 ); 204e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 7 ); 205e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott# endif 206e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#elif !defined (_MSC_VER) 207e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 7 ); 208e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 7 ); 209e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 210e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 14 ); 211e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 14 ); 212e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 213e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 214e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // Following test violate requirements to sequiences (23.1.1 Table 67) 215e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott /* 216e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.insert(vect.begin() + 2, vect.begin(), vect.end()); 217e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 218e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 8 elements 219e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 ); 220e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 8 ); 221e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 7 ); 222e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 ); 223e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott */ 224e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 225e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 226e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vector<CompleteMovableStruct> v2 = vect; 227e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 228e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 0 ); 229e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 230e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 0 ); 231e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 0 ); 232e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 233e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 234e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.insert(vect.begin() + 2, v2.begin(), v2.end()); 235e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 236e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 8 elements 237e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 0 ); 238e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 239e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 240e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 4 ); 241e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 0 ); 242e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 243e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 8 ); 244e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 ); 245e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 246e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 247e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 248e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.begin(), vect.begin() + 2); 249e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 250e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 6 elements 251e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 252e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 6 ); 253e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 254e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 6 ); 255e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 256e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 2 ); 257e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 258e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 259e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.end() - 2, vect.end()); 260e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 261e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 4 elements 262e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 0 ); 263e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 2 ); 264e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 265e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 266e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott vect.erase(vect.begin()); 267e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 268e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // vect contains 3 elements 269e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 270e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 3 ); 271e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 272e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 3 ); 273e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 274e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 1 ); 275e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 276e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 277e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 278e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //vect with 3 elements and v2 with 4 elements are now out of scope 279e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 3 + 4 ); 280e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 281e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 282e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 283e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottvoid MoveConstructorTest::move_traits_deq() 284e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ 285e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 286e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 287e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 288e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deque<MovableStruct> deq; 289e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(MovableStruct()); 290e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(MovableStruct()); 291e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(MovableStruct()); 292e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(MovableStruct()); 293e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 294e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 4 elements 295e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 ); 296e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 297e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 0 ); 298e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 4 ); 299e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 300e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // Following test violate requirements to sequiences (23.1.1 Table 67) 301e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott /* 302e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.insert(deq.begin() + 2, deq.begin(), deq.end()); 303e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 8 elements 304e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 4 ); 305e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 8 ); 306e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 7 ); 307e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 11 ); 308e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott */ 309e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 310e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 311e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deque<MovableStruct> d2 = deq; 312e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 313e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 0 ); 314e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 315e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 0 ); 316e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 0 ); 317e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 318e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 319e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.insert(deq.begin() + 2, d2.begin(), d2.end() ); 320e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 321e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 8 elements 322e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_dft_construct_call == 0 ); 323e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_cpy_construct_call == 4 ); 324e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 325e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 2 ); 326e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 2 ); 327e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 328e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 2 ); 329e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 0 ); 330e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 331e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 332e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 333e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.begin() + 1, deq.begin() + 3 ); 334e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 335e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 6 elements 336e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 337e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 1 ); 338e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 3 ); 339e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 340e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //Following check is highly deque implementation dependant so 341e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //it might not always work... 342e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 1 ); 343e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 2 ); 344e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 345e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 346e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 347e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.end() - 3, deq.end() - 1); 348e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 349e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 4 elements 350e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 351e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 1 ); 352e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 3 ); 353e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 354e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 1 ); 355e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 2 ); 356e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 357e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 358e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 359e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.begin()); 360e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 361e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 3 elements 362e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 363e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_mv_construct_call == 0 ); 364e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 365e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_assignment_call == 0 ); 366e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 367e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 1 ); 368e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 369e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott MovableStruct::reset(); 370e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 371e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //deq with 3 elements and d2 with 4 elements are now out of scope 372e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( MovableStruct::nb_destruct_call == 3 + 4 ); 373e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 374e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 375e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 376e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scottvoid MoveConstructorTest::move_traits_deq_complete() 377e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott{ 378e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 379e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 380e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott { 381e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deque<CompleteMovableStruct> deq; 382e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(CompleteMovableStruct()); 383e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(CompleteMovableStruct()); 384e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(CompleteMovableStruct()); 385e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.push_back(CompleteMovableStruct()); 386e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 387e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 4 elements 388e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 ); 389e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 390e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 0 ); 391e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 ); 392e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 393e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // Following test violate requirements to sequiences (23.1.1 Table 67) 394e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott /* 395e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.insert(deq.begin() + 2, deq.begin(), deq.end()); 396e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 397e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 8 elements 398e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 4 ); 399e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 8 ); 400e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 7 ); 401e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 4 ); 402e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott */ 403e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 404e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 405e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deque<CompleteMovableStruct> d2 = deq; 406e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 407e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 0 ); 408e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 409e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 0 ); 410e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 0 ); 411e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 412e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 413e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.insert(deq.begin() + 2, d2.begin(), d2.end()); 414e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 415e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 8 elements 416e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_dft_construct_call == 0 ); 417e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_cpy_construct_call == 4 ); 418e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 419e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 2 ); 420e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 421e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 2 ); 422e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 423e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 0 ); 424e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 425e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 426e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.begin() + 1, deq.begin() + 3); 427e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 428e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 6 elements 429e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 430e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 1 ); 431e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 432e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 1 ); 433e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 434e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 2 ); 435e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 436e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 437e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.end() - 3, deq.end() - 1); 438e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 439e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 4 elements 440e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC) 441e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 1 ); 442e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#else 443e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 1 ); 444e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott#endif 445e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 2 ); 446e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 447e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 448e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott deq.erase(deq.begin()); 449e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 450e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott // deq contains 3 elements 451e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_mv_construct_call == 0 ); 452e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_assignment_call == 0 ); 453e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 1 ); 454e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott 455e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CompleteMovableStruct::reset(); 456e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 457e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott //deq with 3 elements and v2 with 4 elements are now out of scope 458e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott CPPUNIT_ASSERT( CompleteMovableStruct::nb_destruct_call == 3 + 4 ); 459e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott } 460e46c9386c4f79aa40185f79a19fc5b2a7ef528b3Patrick Scott} 461