Chris@102: /* Chris@102: * Copyright (c) 2014 Glen Joseph Fernandes Chris@102: * glenfe at live dot com Chris@102: * Chris@102: * Distributed under the Boost Software License, Chris@102: * Version 1.0. (See accompanying file LICENSE_1_0.txt Chris@102: * or copy at http://boost.org/LICENSE_1_0.txt) Chris@102: */ Chris@102: #ifndef BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP Chris@102: #define BOOST_SMART_PTR_DETAIL_ARRAY_COUNT_IMPL_HPP Chris@102: Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { Chris@102: namespace detail { Chris@102: template Chris@102: class sp_counted_impl_pda Chris@102: : public sp_counted_base { Chris@102: typedef ms_in_allocator_tag D; Chris@102: typedef sp_counted_impl_pda Y; Chris@102: public: Chris@102: sp_counted_impl_pda(P, D, const A& allocator_) Chris@102: : allocator(allocator_) { Chris@102: } Chris@102: Chris@102: virtual void dispose() { Chris@102: allocator(); Chris@102: } Chris@102: Chris@102: virtual void destroy() { Chris@102: #if !defined(BOOST_NO_CXX11_ALLOCATOR) Chris@102: typedef typename std::allocator_traits:: Chris@102: template rebind_alloc YA; Chris@102: typedef typename std::allocator_traits:: Chris@102: template rebind_traits YT; Chris@102: #else Chris@102: typedef typename A::template rebind::other YA; Chris@102: #endif Chris@102: YA a1(allocator); Chris@102: #if !defined(BOOST_NO_CXX11_ALLOCATOR) Chris@102: YT::destroy(a1, this); Chris@102: YT::deallocate(a1, this, 1); Chris@102: #else Chris@102: this->~Y(); Chris@102: a1.deallocate(this, 1); Chris@102: #endif Chris@102: } Chris@102: Chris@102: virtual void* get_deleter(const sp_typeinfo&) { Chris@102: return &reinterpret_cast(allocator); Chris@102: } Chris@102: Chris@102: virtual void* get_untyped_deleter() { Chris@102: return &reinterpret_cast(allocator); Chris@102: } Chris@102: Chris@102: private: Chris@102: sp_counted_impl_pda(const sp_counted_impl_pda&); Chris@102: sp_counted_impl_pda& operator=(const sp_counted_impl_pda&); Chris@102: Chris@102: A allocator; Chris@102: }; Chris@102: } Chris@102: } Chris@102: Chris@102: #endif