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 // <memory>
11 
12 // template <class OuterAlloc, class... InnerAllocs>
13 //   class scoped_allocator_adaptor
14 
15 // typedef see below is_always_equal;
16 
17 #include <scoped_allocator>
18 #include <type_traits>
19 
20 #include "allocators.h"
21 #include "min_allocator.h"
22 
main()23 int main()
24 {
25 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
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 
74 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
75 }
76