2012-03-22 18:46:18 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// (C) Copyright Pablo Halpern 2009. Distributed under the Boost
|
|
|
|
|
// Software License, Version 1.0. (See accompanying file
|
|
|
|
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
2013-12-23 10:47:20 +01:00
|
|
|
// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost
|
2012-03-22 18:46:18 +00:00
|
|
|
// Software License, Version 1.0. (See accompanying file
|
|
|
|
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
//
|
|
|
|
|
// See http://www.boost.org/libs/container for documentation.
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
#ifndef BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
|
|
|
|
|
#define BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP
|
|
|
|
|
|
2013-09-26 13:02:51 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-03-22 18:46:18 +00:00
|
|
|
# pragma once
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <boost/container/detail/config_begin.hpp>
|
|
|
|
|
#include <boost/container/detail/workaround.hpp>
|
2015-01-02 19:34:21 +01:00
|
|
|
|
|
|
|
|
// container
|
2013-09-26 18:05:25 +00:00
|
|
|
#include <boost/container/container_fwd.hpp>
|
2012-03-22 18:46:18 +00:00
|
|
|
#include <boost/container/detail/mpl.hpp>
|
2014-09-26 08:12:40 +02:00
|
|
|
#include <boost/container/detail/placement_new.hpp>
|
2015-01-02 19:34:21 +01:00
|
|
|
#ifndef BOOST_CONTAINER_DETAIL_STD_FWD_HPP
|
|
|
|
|
#include <boost/container/detail/std_fwd.hpp>
|
|
|
|
|
#endif
|
|
|
|
|
// intrusive
|
2014-12-08 15:49:21 +01:00
|
|
|
#include <boost/intrusive/pointer_traits.hpp>
|
|
|
|
|
#include <boost/intrusive/detail/mpl.hpp>
|
2015-01-02 19:34:21 +01:00
|
|
|
// move
|
2014-09-17 23:36:23 +02:00
|
|
|
#include <boost/move/utility_core.hpp>
|
2015-01-02 19:34:21 +01:00
|
|
|
// move/detail
|
2013-03-03 12:26:48 +00:00
|
|
|
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2015-01-02 19:34:21 +01:00
|
|
|
#include <boost/move/detail/fwd_macros.hpp>
|
2013-03-03 12:26:48 +00:00
|
|
|
#endif
|
2012-03-22 18:46:18 +00:00
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME allocate
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 2
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 2
|
|
|
|
|
#include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
|
|
|
|
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME destroy
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 1
|
|
|
|
|
#include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
|
|
|
|
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME construct
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace container_detail {
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 1
|
|
|
|
|
#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 9
|
|
|
|
|
#include <boost/intrusive/detail/has_member_function_callable_with.hpp>
|
2014-09-26 08:12:40 +02:00
|
|
|
|
2012-03-22 18:46:18 +00:00
|
|
|
namespace boost {
|
|
|
|
|
namespace container {
|
2014-09-26 08:12:40 +02:00
|
|
|
namespace allocator_traits_detail {
|
|
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_max_size, max_size)
|
|
|
|
|
BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_select_on_container_copy_construction, select_on_container_copy_construction)
|
|
|
|
|
|
2014-09-26 08:12:40 +02:00
|
|
|
}
|
2014-06-13 10:49:09 +02:00
|
|
|
|
|
|
|
|
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
|
|
|
|
|
2012-03-22 18:46:18 +00:00
|
|
|
namespace container_detail {
|
|
|
|
|
|
|
|
|
|
//workaround needed for C++03 compilers with no construct()
|
|
|
|
|
//supporting rvalue references
|
2015-01-02 19:34:21 +01:00
|
|
|
template<class Allocator>
|
2012-03-22 18:46:18 +00:00
|
|
|
struct is_std_allocator
|
|
|
|
|
{ static const bool value = false; };
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
|
struct is_std_allocator< std::allocator<T> >
|
|
|
|
|
{ static const bool value = true; };
|
|
|
|
|
|
2014-12-08 15:49:21 +01:00
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
|
2015-01-02 19:34:21 +01:00
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer)
|
2014-12-08 15:49:21 +01:00
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(const_reference)
|
2015-01-02 19:34:21 +01:00
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(void_pointer)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_void_pointer)
|
2014-12-08 15:49:21 +01:00
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(size_type)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_copy_assignment)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_move_assignment)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(propagate_on_container_swap)
|
|
|
|
|
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type)
|
|
|
|
|
|
2012-03-22 18:46:18 +00:00
|
|
|
} //namespace container_detail {
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
2012-03-22 18:46:18 +00:00
|
|
|
|
|
|
|
|
//! The class template allocator_traits supplies a uniform interface to all allocator types.
|
|
|
|
|
//! This class is a C++03-compatible implementation of std::allocator_traits
|
2015-01-02 19:34:21 +01:00
|
|
|
template <typename Allocator>
|
2012-03-22 18:46:18 +00:00
|
|
|
struct allocator_traits
|
|
|
|
|
{
|
|
|
|
|
//allocator_type
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef Allocator allocator_type;
|
2012-03-22 18:46:18 +00:00
|
|
|
//value_type
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef typename allocator_type::value_type value_type;
|
2012-03-22 18:46:18 +00:00
|
|
|
|
|
|
|
|
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::pointer if such a type exists; otherwise, value_type*
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-03-22 18:46:18 +00:00
|
|
|
typedef unspecified pointer;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::const_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<const
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation const_pointer;
|
2012-03-22 18:46:18 +00:00
|
|
|
//! Non-standard extension
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::reference if such a type exists; otherwise, value_type&
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation reference;
|
2012-03-22 18:46:18 +00:00
|
|
|
//! Non-standard extension
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::const_reference if such a type exists ; otherwise, const value_type&
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation const_reference;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::void_pointer if such a type exists ; otherwise, pointer_traits<pointer>::rebind<void>.
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation void_pointer;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::const_void_pointer if such a type exists ; otherwis e, pointer_traits<pointer>::rebind<const
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation const_void_pointer;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::difference_type if such a type exists ; otherwise, pointer_traits<pointer>::difference_type.
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation difference_type;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::size_type if such a type exists ; otherwise, make_unsigned<difference_type>::type
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation size_type;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::propagate_on_container_copy_assignment if such a type exists, otherwise a type
|
|
|
|
|
//! with an internal constant static boolean member <code>value</code> == false.
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation propagate_on_container_copy_assignment;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::propagate_on_container_move_assignment if such a type exists, otherwise otherwise a type
|
|
|
|
|
//! with an internal constant static boolean member <code>value</code> == false.
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation propagate_on_container_move_assignment;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Allocator::propagate_on_container_swap if such a type exists, otherwise an otherwise a type
|
|
|
|
|
//! with an internal constant static boolean member <code>value</code> == false.
|
2012-09-24 10:27:02 +00:00
|
|
|
typedef see_documentation propagate_on_container_swap;
|
2015-01-02 19:34:21 +01:00
|
|
|
//! Defines an allocator: Allocator::rebind<T>::other if such a type exists; otherwise, Allocator<T, Args>
|
|
|
|
|
//! if Allocator is a class template instantiation of the form Allocator<U, Args>, where Args is zero or
|
2012-03-22 18:46:18 +00:00
|
|
|
//! more type arguments ; otherwise, the instantiation of rebind_alloc is ill-formed.
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2013-12-23 10:47:20 +01:00
|
|
|
//! In C++03 compilers <code>rebind_alloc</code> is a struct derived from an allocator
|
2012-03-22 18:46:18 +00:00
|
|
|
//! deduced by previously detailed rules.
|
2012-09-24 10:27:02 +00:00
|
|
|
template <class T> using rebind_alloc = see_documentation;
|
2012-03-22 18:46:18 +00:00
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! In C++03 compilers <code>rebind_traits</code> is a struct derived from
|
|
|
|
|
//! <code>allocator_traits<OtherAlloc></code>, where <code>OtherAlloc</code> is
|
|
|
|
|
//! the allocator deduced by rules explained in <code>rebind_alloc</code>.
|
2012-03-22 18:46:18 +00:00
|
|
|
template <class T> using rebind_traits = allocator_traits<rebind_alloc<T> >;
|
|
|
|
|
|
|
|
|
|
//! Non-standard extension: Portable allocator rebind for C++03 and C++11 compilers.
|
2015-01-02 19:34:21 +01:00
|
|
|
//! <code>type</code> is an allocator related to Allocator deduced deduced by rules explained in <code>rebind_alloc</code>.
|
2012-03-22 18:46:18 +00:00
|
|
|
template <class T>
|
|
|
|
|
struct portable_rebind_alloc
|
2012-09-24 10:27:02 +00:00
|
|
|
{ typedef see_documentation type; };
|
2012-03-22 18:46:18 +00:00
|
|
|
#else
|
|
|
|
|
//pointer
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
pointer, value_type*)
|
|
|
|
|
pointer;
|
|
|
|
|
//const_pointer
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
const_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
|
|
|
|
rebind_pointer<const value_type>)
|
|
|
|
|
const_pointer;
|
|
|
|
|
//reference
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
reference, typename container_detail::unvoid<value_type>::type&)
|
|
|
|
|
reference;
|
|
|
|
|
//const_reference
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
const_reference, const typename container_detail::unvoid<value_type>::type&)
|
|
|
|
|
const_reference;
|
|
|
|
|
//void_pointer
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
void_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
|
|
|
|
rebind_pointer<void>)
|
|
|
|
|
void_pointer;
|
|
|
|
|
//const_void_pointer
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
const_void_pointer, typename boost::intrusive::pointer_traits<pointer>::template
|
|
|
|
|
rebind_pointer<const void>)
|
|
|
|
|
const_void_pointer;
|
|
|
|
|
//difference_type
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
difference_type, std::ptrdiff_t)
|
|
|
|
|
difference_type;
|
|
|
|
|
//size_type
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2012-03-22 18:46:18 +00:00
|
|
|
size_type, std::size_t)
|
|
|
|
|
size_type;
|
|
|
|
|
//propagate_on_container_copy_assignment
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2014-09-26 08:12:40 +02:00
|
|
|
propagate_on_container_copy_assignment, container_detail::false_type)
|
2012-03-22 18:46:18 +00:00
|
|
|
propagate_on_container_copy_assignment;
|
|
|
|
|
//propagate_on_container_move_assignment
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2014-09-26 08:12:40 +02:00
|
|
|
propagate_on_container_move_assignment, container_detail::false_type)
|
2012-03-22 18:46:18 +00:00
|
|
|
propagate_on_container_move_assignment;
|
|
|
|
|
//propagate_on_container_swap
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
|
2014-09-26 08:12:40 +02:00
|
|
|
propagate_on_container_swap, container_detail::false_type)
|
2012-03-22 18:46:18 +00:00
|
|
|
propagate_on_container_swap;
|
|
|
|
|
|
2012-11-20 23:06:46 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
2012-03-22 18:46:18 +00:00
|
|
|
//C++11
|
2015-01-02 19:34:21 +01:00
|
|
|
template <typename T> using rebind_alloc = typename boost::intrusive::pointer_rebind<Allocator, T>::type;
|
2012-03-22 18:46:18 +00:00
|
|
|
template <typename T> using rebind_traits = allocator_traits< rebind_alloc<T> >;
|
2012-11-20 23:06:46 +00:00
|
|
|
#else // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
2012-03-22 18:46:18 +00:00
|
|
|
//Some workaround for C++03 or C++11 compilers with no template aliases
|
|
|
|
|
template <typename T>
|
2015-01-02 19:34:21 +01:00
|
|
|
struct rebind_alloc : boost::intrusive::pointer_rebind<Allocator,T>::type
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
2015-01-02 19:34:21 +01:00
|
|
|
typedef typename boost::intrusive::pointer_rebind<Allocator,T>::type Base;
|
2012-11-20 23:10:46 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2015-01-02 19:34:21 +01:00
|
|
|
template <typename... Args>
|
|
|
|
|
rebind_alloc(BOOST_FWD_REF(Args)... args) : Base(boost::forward<Args>(args)...) {}
|
2012-11-20 23:10:46 +00:00
|
|
|
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2015-01-02 19:34:21 +01:00
|
|
|
#define BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC(N) \
|
|
|
|
|
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
|
|
|
|
|
explicit rebind_alloc(BOOST_MOVE_UREF##N) : Base(BOOST_MOVE_FWD##N){}\
|
|
|
|
|
//
|
|
|
|
|
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC)
|
|
|
|
|
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_REBIND_ALLOC
|
2012-11-20 23:10:46 +00:00
|
|
|
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2012-03-22 18:46:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
struct rebind_traits
|
2015-01-02 19:34:21 +01:00
|
|
|
: allocator_traits<typename boost::intrusive::pointer_rebind<Allocator, T>::type>
|
2012-03-22 18:46:18 +00:00
|
|
|
{};
|
2012-11-20 23:06:46 +00:00
|
|
|
#endif // #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
|
2012-03-22 18:46:18 +00:00
|
|
|
template <class T>
|
|
|
|
|
struct portable_rebind_alloc
|
2015-01-02 19:34:21 +01:00
|
|
|
{ typedef typename boost::intrusive::pointer_rebind<Allocator, T>::type type; };
|
2012-03-22 18:46:18 +00:00
|
|
|
#endif //BOOST_CONTAINER_DOXYGEN_INVOKED
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Returns</b>: <code>a.allocate(n)</code>
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2015-01-02 19:34:21 +01:00
|
|
|
static pointer allocate(Allocator &a, size_type n)
|
2012-03-22 18:46:18 +00:00
|
|
|
{ return a.allocate(n); }
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Returns</b>: <code>a.deallocate(p, n)</code>
|
2012-05-20 10:02:49 +00:00
|
|
|
//!
|
2012-03-22 18:46:18 +00:00
|
|
|
//! <b>Throws</b>: Nothing
|
2015-01-02 19:34:21 +01:00
|
|
|
static void deallocate(Allocator &a, pointer p, size_type n)
|
2013-04-26 19:46:47 +00:00
|
|
|
{ a.deallocate(p, n); }
|
2012-03-22 18:46:18 +00:00
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Effects</b>: calls <code>a.allocate(n, p)</code> if that call is well-formed;
|
|
|
|
|
//! otherwise, invokes <code>a.allocate(n)</code>
|
2015-01-02 19:34:21 +01:00
|
|
|
static pointer allocate(Allocator &a, size_type n, const_void_pointer p)
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
|
|
|
|
const bool value = boost::container::container_detail::
|
|
|
|
|
has_member_function_callable_with_allocate
|
2015-01-02 19:34:21 +01:00
|
|
|
<Allocator, const size_type, const const_void_pointer>::value;
|
2014-09-26 08:12:40 +02:00
|
|
|
container_detail::bool_<value> flag;
|
2012-03-22 18:46:18 +00:00
|
|
|
return allocator_traits::priv_allocate(flag, a, n, p);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Effects</b>: calls <code>a.destroy(p)</code> if that call is well-formed;
|
|
|
|
|
//! otherwise, invokes <code>p->~T()</code>.
|
2012-03-22 18:46:18 +00:00
|
|
|
template<class T>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void destroy(Allocator &a, T*p) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
|
|
|
|
typedef T* destroy_pointer;
|
|
|
|
|
const bool value = boost::container::container_detail::
|
|
|
|
|
has_member_function_callable_with_destroy
|
2015-01-02 19:34:21 +01:00
|
|
|
<Allocator, const destroy_pointer>::value;
|
2014-09-26 08:12:40 +02:00
|
|
|
container_detail::bool_<value> flag;
|
2012-03-22 18:46:18 +00:00
|
|
|
allocator_traits::priv_destroy(flag, a, p);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Returns</b>: <code>a.max_size()</code> if that expression is well-formed; otherwise,
|
|
|
|
|
//! <code>numeric_limits<size_type>::max()</code>.
|
2015-01-02 19:34:21 +01:00
|
|
|
static size_type max_size(const Allocator &a) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
2015-01-02 19:34:21 +01:00
|
|
|
const bool value = allocator_traits_detail::has_max_size<Allocator, size_type (Allocator::*)() const>::value;
|
2014-09-26 08:12:40 +02:00
|
|
|
container_detail::bool_<value> flag;
|
2012-03-22 18:46:18 +00:00
|
|
|
return allocator_traits::priv_max_size(flag, a);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Returns</b>: <code>a.select_on_container_copy_construction()</code> if that expression is well-formed;
|
2012-03-22 18:46:18 +00:00
|
|
|
//! otherwise, a.
|
2013-02-24 13:13:36 +00:00
|
|
|
static
|
|
|
|
|
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
|
|
|
|
typename container_detail::if_c
|
2015-01-02 19:34:21 +01:00
|
|
|
< allocator_traits_detail::has_select_on_container_copy_construction<Allocator, Allocator (Allocator::*)() const>::value
|
|
|
|
|
, Allocator
|
|
|
|
|
, const Allocator &
|
2013-02-24 13:13:36 +00:00
|
|
|
>::type
|
|
|
|
|
#else
|
2015-01-02 19:34:21 +01:00
|
|
|
Allocator
|
2013-02-24 13:13:36 +00:00
|
|
|
#endif
|
2015-01-02 19:34:21 +01:00
|
|
|
select_on_container_copy_construction(const Allocator &a)
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
2015-01-02 19:34:21 +01:00
|
|
|
const bool value = allocator_traits_detail::has_select_on_container_copy_construction
|
|
|
|
|
<Allocator, Allocator (Allocator::*)() const>::value;
|
2014-09-26 08:12:40 +02:00
|
|
|
container_detail::bool_<value> flag;
|
2012-03-22 18:46:18 +00:00
|
|
|
return allocator_traits::priv_select_on_container_copy_construction(flag, a);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 23:10:46 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
2013-12-23 10:47:20 +01:00
|
|
|
//! <b>Effects</b>: calls <code>a.construct(p, std::forward<Args>(args)...)</code> if that call is well-formed;
|
|
|
|
|
//! otherwise, invokes <code>::new (static_cast<void*>(p)) T(std::forward<Args>(args)...)</code>
|
2012-03-22 18:46:18 +00:00
|
|
|
template <class T, class ...Args>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args)
|
2012-03-22 18:46:18 +00:00
|
|
|
{
|
2015-01-02 19:34:21 +01:00
|
|
|
container_detail::bool_<container_detail::is_std_allocator<Allocator>::value> flag;
|
2012-03-22 18:46:18 +00:00
|
|
|
allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2013-12-23 10:47:20 +01:00
|
|
|
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
2012-03-22 18:46:18 +00:00
|
|
|
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
|
|
|
|
private:
|
2015-01-02 19:34:21 +01:00
|
|
|
static pointer priv_allocate(container_detail::true_type, Allocator &a, size_type n, const_void_pointer p)
|
2012-03-22 18:46:18 +00:00
|
|
|
{ return a.allocate(n, p); }
|
|
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
static pointer priv_allocate(container_detail::false_type, Allocator &a, size_type n, const_void_pointer)
|
2014-12-08 15:49:21 +01:00
|
|
|
{ return a.allocate(n); }
|
2012-03-22 18:46:18 +00:00
|
|
|
|
|
|
|
|
template<class T>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_destroy(container_detail::true_type, Allocator &a, T* p) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{ a.destroy(p); }
|
|
|
|
|
|
|
|
|
|
template<class T>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_destroy(container_detail::false_type, Allocator &, T* p) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{ p->~T(); (void)p; }
|
|
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
static size_type priv_max_size(container_detail::true_type, const Allocator &a) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{ return a.max_size(); }
|
|
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
static size_type priv_max_size(container_detail::false_type, const Allocator &) BOOST_CONTAINER_NOEXCEPT
|
2014-09-26 08:12:40 +02:00
|
|
|
{ return size_type(-1); }
|
2012-03-22 18:46:18 +00:00
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
static Allocator priv_select_on_container_copy_construction(container_detail::true_type, const Allocator &a)
|
2012-03-22 18:46:18 +00:00
|
|
|
{ return a.select_on_container_copy_construction(); }
|
|
|
|
|
|
2015-01-02 19:34:21 +01:00
|
|
|
static const Allocator &priv_select_on_container_copy_construction(container_detail::false_type, const Allocator &a) BOOST_CONTAINER_NOEXCEPT
|
2012-03-22 18:46:18 +00:00
|
|
|
{ return a; }
|
|
|
|
|
|
2012-11-20 23:10:46 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2012-03-22 18:46:18 +00:00
|
|
|
template<class T, class ...Args>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_construct(container_detail::false_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
2014-05-28 15:50:13 +02:00
|
|
|
{
|
2012-03-22 18:46:18 +00:00
|
|
|
const bool value = boost::container::container_detail::
|
|
|
|
|
has_member_function_callable_with_construct
|
2015-01-02 19:34:21 +01:00
|
|
|
< Allocator, T*, Args... >::value;
|
2014-09-26 08:12:40 +02:00
|
|
|
container_detail::bool_<value> flag;
|
2015-01-02 19:34:21 +01:00
|
|
|
(priv_construct_dispatch_next)(flag, a, p, ::boost::forward<Args>(args)...);
|
2012-03-22 18:46:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class T, class ...Args>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_construct(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
|
|
|
|
{ (priv_construct_dispatch_next)(container_detail::false_type(), a, p, ::boost::forward<Args>(args)...); }
|
2012-03-22 18:46:18 +00:00
|
|
|
|
|
|
|
|
template<class T, class ...Args>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_construct_dispatch_next(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
|
2012-03-22 18:46:18 +00:00
|
|
|
{ a.construct( p, ::boost::forward<Args>(args)...); }
|
|
|
|
|
|
|
|
|
|
template<class T, class ...Args>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args)
|
2014-09-26 08:12:40 +02:00
|
|
|
{ ::new((void*)p, boost_container_new_t()) T(::boost::forward<Args>(args)...); }
|
2012-11-20 23:10:46 +00:00
|
|
|
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2012-03-22 18:46:18 +00:00
|
|
|
public:
|
2015-01-02 19:34:21 +01:00
|
|
|
|
|
|
|
|
#define BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL(N) \
|
|
|
|
|
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
|
|
|
|
static void construct(Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
|
|
|
|
{\
|
|
|
|
|
container_detail::bool_<container_detail::is_std_allocator<Allocator>::value> flag;\
|
|
|
|
|
(priv_construct)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
|
|
|
|
}\
|
2012-03-22 18:46:18 +00:00
|
|
|
//
|
2015-01-02 19:34:21 +01:00
|
|
|
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL)
|
|
|
|
|
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL
|
2014-05-28 15:50:13 +02:00
|
|
|
|
2012-03-22 18:46:18 +00:00
|
|
|
private:
|
2015-01-02 19:34:21 +01:00
|
|
|
|
|
|
|
|
#define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL(N) \
|
|
|
|
|
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
|
|
|
|
static void priv_construct(container_detail::false_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
|
|
|
|
{\
|
|
|
|
|
const bool value = boost::container::container_detail::has_member_function_callable_with_construct\
|
|
|
|
|
< Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_FWD_T##N>::value;\
|
|
|
|
|
container_detail::bool_<value> flag;\
|
|
|
|
|
(priv_construct_dispatch_next)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
|
|
|
|
}\
|
|
|
|
|
\
|
|
|
|
|
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
|
|
|
|
static void priv_construct(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
|
|
|
|
{ (priv_construct_dispatch_next)(container_detail::false_type(), a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
|
|
|
|
|
\
|
|
|
|
|
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
|
|
|
|
static void priv_construct_dispatch_next(container_detail::true_type, Allocator &a, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
|
|
|
|
{ a.construct( p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); }\
|
|
|
|
|
\
|
|
|
|
|
template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
|
|
|
|
static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
|
|
|
|
{ ::new((void*)p, boost_container_new_t()) T(BOOST_MOVE_FWD##N); }\
|
2012-03-22 18:46:18 +00:00
|
|
|
//
|
2015-01-02 19:34:21 +01:00
|
|
|
BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL)
|
|
|
|
|
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL
|
2012-11-20 23:10:46 +00:00
|
|
|
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
2013-09-26 18:05:25 +00:00
|
|
|
|
|
|
|
|
template<class T>
|
2015-01-02 19:34:21 +01:00
|
|
|
static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&)
|
2013-09-26 18:05:25 +00:00
|
|
|
{ ::new((void*)p) T; }
|
2012-03-22 18:46:18 +00:00
|
|
|
#endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
|
|
|
|
|
2013-12-23 10:47:20 +01:00
|
|
|
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
2012-03-22 18:46:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} //namespace container {
|
|
|
|
|
} //namespace boost {
|
|
|
|
|
|
|
|
|
|
#include <boost/container/detail/config_end.hpp>
|
|
|
|
|
|
|
|
|
|
#endif // ! defined(BOOST_CONTAINER_ALLOCATOR_ALLOCATOR_TRAITS_HPP)
|