WSJT-X/boost/boost/smart_ptr/detail/array_count_impl.hpp
Bill Somerville ecaa982b9f Merged latest version of the boost 1.63.0 vendor drop
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7593 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-03-02 02:45:29 +00:00

68 lines
2.1 KiB
C++

/*
* 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 <boost/smart_ptr/detail/array_allocator.hpp>
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
namespace boost {
namespace detail {
template<class P, class A>
class sp_counted_impl_pda<P, ms_in_allocator_tag, A>
: public sp_counted_base {
typedef ms_in_allocator_tag D;
typedef sp_counted_impl_pda<P, D, A> 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<A>::
template rebind_alloc<Y> YA;
typedef typename std::allocator_traits<A>::
template rebind_traits<Y> YT;
#else
typedef typename A::template rebind<Y>::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<char&>(allocator);
}
virtual void* get_untyped_deleter() {
return &reinterpret_cast<char&>(allocator);
}
private:
sp_counted_impl_pda(const sp_counted_impl_pda&);
sp_counted_impl_pda& operator=(const sp_counted_impl_pda&);
A allocator;
};
}
}
#endif