123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #ifndef BOOST_STATECHART_DETAIL_MEMORY_HPP_INCLUDED
- #define BOOST_STATECHART_DETAIL_MEMORY_HPP_INCLUDED
- #include <boost/statechart/detail/avoid_unused_warning.hpp>
- #include <boost/assert.hpp>
- #include <boost/detail/allocator_utilities.hpp>
- #include <cstddef> // std::size_t
- #include <memory> // std::allocator_traits
- namespace boost
- {
- namespace statechart
- {
- #ifdef BOOST_NO_CXX11_ALLOCATOR
- typedef void none;
- #else
- struct none {};
- #endif
- namespace detail
- {
- template< class MostDerived, class Allocator >
- void * allocate( std::size_t size )
- {
- avoid_unused_warning( size );
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- BOOST_ASSERT( size == sizeof( MostDerived ) );
- typedef typename boost::detail::allocator::rebind_to<
- Allocator, MostDerived
- >::type md_allocator;
- md_allocator alloc;
- #ifdef BOOST_NO_CXX11_ALLOCATOR
- return alloc.allocate( 1, static_cast< MostDerived * >( 0 ) );
- #else
- typedef std::allocator_traits<md_allocator> md_traits;
- return md_traits::allocate( alloc, 1, static_cast< MostDerived * >( 0 ) );
- #endif
- }
- template< class MostDerived, class Allocator >
- void deallocate( void * pObject )
- {
- typedef typename boost::detail::allocator::rebind_to<
- Allocator, MostDerived
- >::type md_allocator;
- md_allocator alloc;
- #ifdef BOOST_NO_CXX11_ALLOCATOR
- alloc.deallocate( static_cast< MostDerived * >( pObject ), 1 );
- #else
- typedef std::allocator_traits<md_allocator> md_traits;
- md_traits::deallocate( alloc, static_cast< MostDerived * >( pObject ), 1 );
- #endif
- }
- }
- }
- }
- #endif
|