libcxx

libcxx mirror with random patches
git clone https://git.neptards.moe/neptards/libcxx.git
Log | Files | Refs

copy_assign.pass.cpp (2195B)


      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 // UNSUPPORTED: c++98, c++03
     11 
     12 // <memory>
     13 
     14 // template <class OuterAlloc, class... InnerAllocs>
     15 //   class scoped_allocator_adaptor
     16 
     17 // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor& other);
     18 
     19 
     20 #include <scoped_allocator>
     21 #include <cassert>
     22 
     23 #include "allocators.h"
     24 
     25 int main()
     26 {
     27     {
     28         typedef std::scoped_allocator_adaptor<A1<int>> A;
     29         A a1(A1<int>(3));
     30         A aN;
     31         A1<int>::copy_called = false;
     32         A1<int>::move_called = false;
     33         aN = a1;
     34         assert(A1<int>::copy_called == true);
     35         assert(A1<int>::move_called == false);
     36         assert(aN == a1);
     37     }
     38     {
     39         typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
     40         A a1(A1<int>(4), A2<int>(5));
     41         A aN;
     42         A1<int>::copy_called = false;
     43         A1<int>::move_called = false;
     44         A2<int>::copy_called = false;
     45         A2<int>::move_called = false;
     46         aN = a1;
     47         assert(A1<int>::copy_called == true);
     48         assert(A1<int>::move_called == false);
     49         assert(A2<int>::copy_called == true);
     50         assert(A2<int>::move_called == false);
     51         assert(aN == a1);
     52     }
     53     {
     54         typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
     55         A a1(A1<int>(4), A2<int>(5), A3<int>(6));
     56         A aN;
     57         A1<int>::copy_called = false;
     58         A1<int>::move_called = false;
     59         A2<int>::copy_called = false;
     60         A2<int>::move_called = false;
     61         A3<int>::copy_called = false;
     62         A3<int>::move_called = false;
     63         aN = a1;
     64         assert(A1<int>::copy_called == true);
     65         assert(A1<int>::move_called == false);
     66         assert(A2<int>::copy_called == true);
     67         assert(A2<int>::move_called == false);
     68         assert(A3<int>::copy_called == true);
     69         assert(A3<int>::move_called == false);
     70         assert(aN == a1);
     71     }
     72 }