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