]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/config/test/boost_has_part_alloc.ipp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / config / test / boost_has_part_alloc.ipp
1 // (C) Copyright John Maddock 2001.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 // See http://www.boost.org/libs/config for most recent version.
7
8 // MACRO: BOOST_HAS_PARTIAL_STD_ALLOCATOR
9 // TITLE: limited std::allocator support
10 // DESCRIPTION: The std lib has at least some kind of stanfard allocator
11 // with allocate/deallocate members and probably not much more.
12
13 #include <memory>
14
15 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
16 # define BOOST_UNUSED_ATTRIBUTE __attribute__((unused))
17 #else
18 # define BOOST_UNUSED_ATTRIBUTE
19 #endif
20
21 namespace boost_has_partial_std_allocator{
22
23 //
24 // test everything except rebind template members:
25 //
26
27 template <class T>
28 int test_allocator(const T& i)
29 {
30 typedef std::allocator<int> alloc1_t;
31 typedef typename alloc1_t::size_type size_type;
32 typedef typename alloc1_t::difference_type difference_type BOOST_UNUSED_ATTRIBUTE;
33 typedef typename alloc1_t::pointer pointer;
34 typedef typename alloc1_t::const_pointer const_pointer;
35 typedef typename alloc1_t::reference reference;
36 typedef typename alloc1_t::const_reference const_reference;
37 typedef typename alloc1_t::value_type value_type BOOST_UNUSED_ATTRIBUTE;
38
39 alloc1_t a1;
40
41 pointer p = a1.allocate(1);
42 const_pointer cp = p;
43 a1.construct(p,i);
44 size_type s = a1.max_size();
45 (void)s;
46 reference r = *p;
47 const_reference cr = *cp;
48 if(p != a1.address(r)) return -1;
49 if(cp != a1.address(cr)) return -1;
50 a1.destroy(p);
51 a1.deallocate(p,1);
52
53 return 0;
54 }
55
56
57 int test()
58 {
59 return test_allocator(0);
60 }
61
62 }
63
64 #undef BOOST_UNUSED_ATTRIBUTE
65