types.pass.cpp revision b8f787b18830ae120fc195f47735a02e84d1a344
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//     : public OuterAlloc
15// {
16// public:
17//     typedef OuterAlloc outer_allocator_type;
18//     typedef typename OuterTraits::size_type size_type;
19//     typedef typename OuterTraits::difference_type difference_type;
20//     typedef typename OuterTraits::pointer pointer;
21//     typedef typename OuterTraits::const_pointer const_pointer;
22//     typedef typename OuterTraits::void_pointer void_pointer;
23//     typedef typename OuterTraits::const_void_pointer const_void_pointer;
24// };
25
26#include <scoped_allocator>
27#include <type_traits>
28
29#include "allocators.h"
30
31int main()
32{
33#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
34
35    static_assert((std::is_base_of<
36        A1<int>,
37        std::scoped_allocator_adaptor<A1<int>>
38        >::value), "");
39
40    static_assert((std::is_same<
41        std::scoped_allocator_adaptor<A1<int>>::outer_allocator_type,
42        A1<int>>::value), "");
43
44    static_assert((std::is_same<
45        std::scoped_allocator_adaptor<A1<int>>::size_type,
46        std::make_unsigned<std::ptrdiff_t>::type>::value), "");
47
48    static_assert((std::is_same<
49        std::scoped_allocator_adaptor<A1<int>>::difference_type,
50        std::ptrdiff_t>::value), "");
51
52    static_assert((std::is_same<
53        std::scoped_allocator_adaptor<A1<int>>::pointer,
54        int*>::value), "");
55
56    static_assert((std::is_same<
57        std::scoped_allocator_adaptor<A1<int>>::const_pointer,
58        const int*>::value), "");
59
60    static_assert((std::is_same<
61        std::scoped_allocator_adaptor<A1<int>>::void_pointer,
62        void*>::value), "");
63
64    static_assert((std::is_same<
65        std::scoped_allocator_adaptor<A1<int>>::const_void_pointer,
66        const void*>::value), "");
67
68    static_assert((std::is_base_of<
69        A2<int>,
70        std::scoped_allocator_adaptor<A2<int>, A1<int>>
71        >::value), "");
72
73    static_assert((std::is_same<
74        std::scoped_allocator_adaptor<A2<int>, A1<int>>::outer_allocator_type,
75        A2<int>>::value), "");
76
77    static_assert((std::is_same<
78        std::scoped_allocator_adaptor<A2<int>, A1<int>>::size_type,
79        unsigned>::value), "");
80
81    static_assert((std::is_same<
82        std::scoped_allocator_adaptor<A2<int>, A1<int>>::difference_type,
83        int>::value), "");
84
85    static_assert((std::is_same<
86        std::scoped_allocator_adaptor<A2<int>, A1<int>>::pointer,
87        int*>::value), "");
88
89    static_assert((std::is_same<
90        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_pointer,
91        const int*>::value), "");
92
93    static_assert((std::is_same<
94        std::scoped_allocator_adaptor<A2<int>, A1<int>>::void_pointer,
95        void*>::value), "");
96
97    static_assert((std::is_same<
98        std::scoped_allocator_adaptor<A2<int>, A1<int>>::const_void_pointer,
99        const void*>::value), "");
100
101#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
102}
103