]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/align/test/aligned_allocator_adaptor_incomplete_test.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / align / test / aligned_allocator_adaptor_incomplete_test.cpp
1 /*
2 Copyright 2018 Glen Joseph Fernandes
3 (glenjofe@gmail.com)
4
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
7 */
8 #include <boost/align/aligned_allocator_adaptor.hpp>
9
10 template<class T>
11 class A {
12 public:
13 typedef T value_type;
14 typedef T* pointer;
15 typedef std::size_t size_type;
16 typedef std::ptrdiff_t difference_type;
17
18 template<class U>
19 struct rebind {
20 typedef A<U> other;
21 };
22
23 A(int state)
24 : state_(state) { }
25
26 template<class U>
27 A(const A<U>& other)
28 : state_(other.state()) { }
29
30 T* allocate(std::size_t size, const void* = 0) {
31 return static_cast<T*>(::operator new(sizeof(T) * size));
32 }
33
34 void deallocate(T* ptr, std::size_t) {
35 ::operator delete(ptr);
36 }
37
38 int state() const {
39 return state_;
40 }
41
42 private:
43 int state_;
44 };
45
46 template<class T, class U>
47 inline bool
48 operator==(const A<T>& a, const A<U>& b)
49 {
50 return a.state() == b.state();
51 }
52
53 template<class T, class U>
54 inline bool
55 operator!=(const A<T>& a, const A<U>& b)
56 {
57 return !(a == b);
58 }
59
60 struct S;
61 struct V { };
62
63 void value_test()
64 {
65 boost::alignment::aligned_allocator_adaptor<A<S> > a(A<S>(1));
66 (void)a;
67 }
68
69 void rebind_test()
70 {
71 boost::alignment::aligned_allocator_adaptor<A<V> > a(A<V>(1));
72 boost::alignment::aligned_allocator_adaptor<A<V> >::rebind<S>::other r(a);
73 (void)r;
74 }