]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/smart_ptr/test/shared_ptr_alloc11_test.cpp
1 #include <boost/config.hpp>
3 // shared_ptr_alloc11_test.cpp
5 // Test the allocator constructor with a C++11 minimal allocator
7 // Copyright (c) 2005, 2014 Peter Dimov
9 // Distributed under the Boost Software License, Version 1.0.
10 // See accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt
14 #include <boost/detail/lightweight_test.hpp>
15 #include <boost/shared_ptr.hpp>
19 #if !defined( BOOST_NO_CXX11_ALLOCATOR )
21 template< class T
> class cxx11_allocator
31 template< class Y
> cxx11_allocator( cxx11_allocator
<Y
> const & )
35 T
* allocate( std::size_t n
)
37 return static_cast< T
* >( ::operator new( n
* sizeof( T
) ) );
40 void deallocate( T
* p
, std::size_t n
)
42 ::operator delete( p
);
54 X(): deleted_( false )
61 BOOST_TEST( deleted_
);
72 X
& operator=( X
const & );
79 void operator()( X
* px
) const
88 BOOST_TEST( X::instances
== 0 );
90 boost::shared_ptr
<void> pv( new X
, D(), cxx11_allocator
<X
>() );
92 BOOST_TEST( X::instances
== 1 );
96 BOOST_TEST( X::instances
== 0 );
98 pv
.reset( new X
, D(), cxx11_allocator
<void>() );
100 BOOST_TEST( X::instances
== 1 );
104 BOOST_TEST( X::instances
== 0 );
106 return boost::report_errors();
109 #else // !defined( BOOST_NO_CXX11_ALLOCATOR )