Home | History | Annotate | Download | only in allocator.adaptor.types
      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 // typedef see below is_always_equal;
     18 
     19 #include <scoped_allocator>
     20 #include <type_traits>
     21 
     22 #include "allocators.h"
     23 #include "min_allocator.h"
     24 
     25 int main()
     26 {
     27     // sanity checks
     28     static_assert( (std::is_same<
     29     		std::allocator_traits<A1<int>>::is_always_equal, std::false_type>::value
     30     		), "" );
     31 
     32     static_assert( (std::is_same<
     33     		std::allocator_traits<min_allocator<int>>::is_always_equal, std::true_type>::value
     34     		), "" );
     35 
     36     // wrapping one allocator
     37     static_assert(
     38         (std::is_same<
     39             std::scoped_allocator_adaptor<A1<int>>::is_always_equal,
     40             std::allocator_traits<A1<int>>::is_always_equal
     41         >::value), "");
     42 
     43     // wrapping one allocator
     44     static_assert(
     45         (std::is_same<
     46             std::scoped_allocator_adaptor<min_allocator<int>>::is_always_equal,
     47             std::allocator_traits<min_allocator<int>>::is_always_equal
     48         >::value), "");
     49 
     50     // wrapping two allocators (check the values instead of the types)
     51     static_assert((
     52             std::scoped_allocator_adaptor<A1<int>, A2<int>>::is_always_equal::value ==
     53             ( std::allocator_traits<A1<int>>::is_always_equal::value &&
     54               std::allocator_traits<A2<int>>::is_always_equal::value)
     55         ), "");
     56 
     57     // wrapping two allocators (check the values instead of the types)
     58     static_assert((
     59             std::scoped_allocator_adaptor<A1<int>, min_allocator<int>>::is_always_equal::value ==
     60             ( std::allocator_traits<A1<int>>::is_always_equal::value &&
     61               std::allocator_traits<min_allocator<int>>::is_always_equal::value)
     62         ), "");
     63 
     64 
     65     // wrapping three allocators (check the values instead of the types)
     66     static_assert((
     67             std::scoped_allocator_adaptor<A1<int>, A2<int>, A3<int>>::is_always_equal::value ==
     68             ( std::allocator_traits<A1<int>>::is_always_equal::value &&
     69               std::allocator_traits<A2<int>>::is_always_equal::value &&
     70               std::allocator_traits<A3<int>>::is_always_equal::value)
     71         ), "");
     72 }
     73