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)
6 // See http://www.boost.org/libs/config for the most recent version.
8 // MACRO: BOOST_NO_STD_ALLOCATOR
9 // TITLE: std::allocator
10 // DESCRIPTION: The C++ standard library does not provide
11 // a standards conforming std::allocator.
13 #ifndef BOOST_NESTED_TEMPLATE
14 #define BOOST_NESTED_TEMPLATE template
19 namespace boost_no_std_allocator{
21 #if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
22 # define BOOST_UNUSED_ATTRIBUTE __attribute__((unused))
24 # define BOOST_UNUSED_ATTRIBUTE
28 int test_allocator(const T& i)
30 typedef std::allocator<int> alloc1_t;
31 #if !((__cplusplus > 201700) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201700)))
32 // stuff deprecated in C++17:
33 typedef typename alloc1_t::size_type size_type;
34 typedef typename alloc1_t::difference_type difference_type BOOST_UNUSED_ATTRIBUTE;
35 typedef typename alloc1_t::pointer pointer;
36 typedef typename alloc1_t::const_pointer const_pointer;
37 typedef typename alloc1_t::reference reference;
38 typedef typename alloc1_t::const_reference const_reference;
40 typedef typename alloc1_t::value_type value_type BOOST_UNUSED_ATTRIBUTE;
45 #if !((__cplusplus > 201700) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201700)))
46 // stuff deprecated in C++17:
47 typedef typename alloc1_t::BOOST_NESTED_TEMPLATE rebind<double> binder_t;
48 typedef typename binder_t::other alloc2_t;
50 // this chokes early versions of the MSL library
51 // and isn't currently required by anything in boost
52 // so don't test for now...
58 #if !((__cplusplus > 201700) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201700)))
59 pointer p = a1.allocate(1);
62 size_type s = a1.max_size();
65 const_reference cr = *cp;
66 if(p != a1.address(r)) return -1;
67 if(cp != a1.address(cr)) return -1;
70 auto p = a1.allocate(1);
80 return test_allocator(0);
85 #undef BOOST_UNUSED_ATTRIBUTE