]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/alloc_construct_cxx11_test.cpp
2 Copyright 2019 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #include <boost/config.hpp>
9 #if !defined(BOOST_NO_CXX11_ALLOCATOR)
10 #include <boost/core/alloc_construct.hpp>
11 #include <boost/core/lightweight_test.hpp>
14 # pragma warning(disable: 4100) // unreferenced parameter 'ptr'
30 type
& operator=(const type
&);
44 creator(const creator
<U
>&) { }
46 T
* allocate(std::size_t size
) {
47 return static_cast<T
*>(::operator new(sizeof(T
) * size
));
50 void deallocate(T
* ptr
, std::size_t) {
51 ::operator delete(ptr
);
55 void construct(type
* ptr
, const V
& value
) {
56 ::new(static_cast<void*>(ptr
)) type(value
+ 1);
60 void destroy(type
* ptr
) {
69 type
* p
= a
.allocate(1);
70 boost::alloc_construct(a
, p
, 1);
71 BOOST_TEST_EQ(type::count
, 1);
72 BOOST_TEST_EQ(p
->value(), 2);
73 boost::alloc_destroy(a
, p
);
74 BOOST_TEST_EQ(type::count
, 0);
75 return boost::report_errors();