libcxx

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

default.pass.cpp (1816B)


      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();
     18 
     19 #include <scoped_allocator>
     20 #include <cassert>
     21 
     22 #include "allocators.h"
     23 
     24 int main()
     25 {
     26     {
     27         typedef std::scoped_allocator_adaptor<A1<int>> A;
     28         A a;
     29         assert(a.outer_allocator() == A1<int>());
     30         assert(a.inner_allocator() == a);
     31         assert(A1<int>::copy_called == false);
     32         assert(A1<int>::move_called == false);
     33     }
     34     {
     35         typedef std::scoped_allocator_adaptor<A1<int>, A2<int>> A;
     36         A a;
     37         assert(a.outer_allocator() == A1<int>());
     38         assert(a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>>());
     39         assert(A1<int>::copy_called == false);
     40         assert(A1<int>::move_called == false);
     41         assert(A2<int>::copy_called == false);
     42         assert(A2<int>::move_called == false);
     43     }
     44     {
     45         typedef std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>> A;
     46         A a;
     47         assert(a.outer_allocator() == A1<int>());
     48         assert((a.inner_allocator() == std::scoped_allocator_adaptor<A2<int>, A3<int>>()));
     49         assert(A1<int>::copy_called == false);
     50         assert(A1<int>::move_called == false);
     51         assert(A2<int>::copy_called == false);
     52         assert(A2<int>::move_called == false);
     53         assert(A3<int>::copy_called == false);
     54         assert(A3<int>::move_called == false);
     55     }
     56 
     57 }