mirror of
https://github.com/boostorg/container.git
synced 2026-02-27 04:52:22 +00:00
Typedef'ed allocator_arg_t as "const std::allocator_arg_t &" to improve interoperability between C++11 allocator-aware types.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
#ifndef BOOST_CONTAINER_DETAIL_ALLOCATOR_ARG_HPP
|
||||
#define BOOST_CONTAINER_DETAIL_ALLOCATOR_ARG_HPP
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (C) Copyright Ion Gaztanaga 2014-2015. 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)
|
||||
//
|
||||
// See http://www.boost.org/libs/container for documentation.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/container/detail/std_fwd.hpp>
|
||||
|
||||
namespace boost { namespace container {
|
||||
|
||||
template<int Dummy = 0>
|
||||
struct alloc_arg
|
||||
{
|
||||
static const std::allocator_arg_t &get() { return *palloc_arg; }
|
||||
static std::allocator_arg_t *palloc_arg;
|
||||
};
|
||||
|
||||
template<int Dummy>
|
||||
std::allocator_arg_t *alloc_arg<Dummy>::palloc_arg;
|
||||
|
||||
}} //namespace boost { namespace container {
|
||||
|
||||
#endif //BOOST_CONTAINER_DETAIL_ALLOCATOR_ARG_HPP
|
||||
@@ -31,7 +31,6 @@
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/detail/std_allocator_arg.hpp>
|
||||
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
@@ -136,10 +135,6 @@ template <class T>
|
||||
struct constructible_with_allocator_prefix
|
||||
{ static const bool value = false; };
|
||||
|
||||
template <class T>
|
||||
struct constructible_with_std_allocator_prefix
|
||||
{ static const bool value = false; };
|
||||
|
||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
namespace container_detail {
|
||||
@@ -297,11 +292,6 @@ namespace container_detail {
|
||||
: is_constructible<T, allocator_arg_t, InnerAlloc, Args...>
|
||||
{};
|
||||
|
||||
template <class T, class InnerAlloc, class ...Args>
|
||||
struct is_constructible_with_std_allocator_prefix
|
||||
: is_constructible<T, const std::allocator_arg_t&, InnerAlloc, Args...>
|
||||
{};
|
||||
|
||||
#else // #if !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
//Without advanced SFINAE expressions, we can't use is_constructible
|
||||
@@ -314,11 +304,6 @@ namespace container_detail {
|
||||
: constructible_with_allocator_prefix<T>
|
||||
{};
|
||||
|
||||
template <class T, class InnerAlloc, class ...Args>
|
||||
struct is_constructible_with_std_allocator_prefix
|
||||
: constructible_with_std_allocator_prefix<T>
|
||||
{};
|
||||
|
||||
template <class T, class InnerAlloc, class ...Args>
|
||||
struct is_constructible_with_allocator_suffix
|
||||
: constructible_with_allocator_suffix<T>
|
||||
@@ -331,11 +316,6 @@ namespace container_detail {
|
||||
: constructible_with_allocator_prefix<T>
|
||||
{};
|
||||
|
||||
template <class T, class InnerAlloc, BOOST_MOVE_CLASSDFLT9>
|
||||
struct is_constructible_with_std_allocator_prefix
|
||||
: constructible_with_std_allocator_prefix<T>
|
||||
{};
|
||||
|
||||
template <class T, class InnerAlloc, BOOST_MOVE_CLASSDFLT9>
|
||||
struct is_constructible_with_allocator_suffix
|
||||
: constructible_with_allocator_suffix<T>
|
||||
@@ -354,27 +334,14 @@ template < typename OutermostAlloc
|
||||
, class ...Args
|
||||
>
|
||||
inline void dispatch_allocator_prefix_suffix
|
||||
( unsigned_<1> use_alloc_prefix, OutermostAlloc& outermost_alloc
|
||||
( true_type use_alloc_prefix, OutermostAlloc& outermost_alloc
|
||||
, InnerAlloc& inner_alloc, T* p, BOOST_FWD_REF(Args) ...args)
|
||||
{
|
||||
(void)use_alloc_prefix;
|
||||
allocator_traits<OutermostAlloc>::construct
|
||||
( outermost_alloc, p, allocator_arg, inner_alloc, ::boost::forward<Args>(args)...);
|
||||
}
|
||||
// std::allocator_arg_t
|
||||
template < typename OutermostAlloc
|
||||
, typename InnerAlloc
|
||||
, typename T
|
||||
, class ...Args
|
||||
>
|
||||
inline void dispatch_allocator_prefix_suffix
|
||||
( unsigned_<2> use_alloc_prefix, OutermostAlloc& outermost_alloc
|
||||
, InnerAlloc &inner_alloc, T* p, BOOST_FWD_REF(Args)...args)
|
||||
{
|
||||
(void)use_alloc_prefix;
|
||||
allocator_traits<OutermostAlloc>::construct
|
||||
( outermost_alloc, p, alloc_arg<>::get(), inner_alloc, ::boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// allocator suffix
|
||||
template < typename OutermostAlloc
|
||||
, typename InnerAlloc
|
||||
@@ -382,7 +349,7 @@ template < typename OutermostAlloc
|
||||
, class ...Args
|
||||
>
|
||||
inline void dispatch_allocator_prefix_suffix
|
||||
( unsigned_<0> use_alloc_prefix, OutermostAlloc& outermost_alloc
|
||||
( false_type use_alloc_prefix, OutermostAlloc& outermost_alloc
|
||||
, InnerAlloc &inner_alloc, T* p, BOOST_FWD_REF(Args)...args)
|
||||
{
|
||||
(void)use_alloc_prefix;
|
||||
@@ -403,8 +370,7 @@ inline void dispatch_uses_allocator
|
||||
//BOOST_STATIC_ASSERT((is_constructible_with_allocator_prefix<T, InnerAlloc, Args...>::value ||
|
||||
// is_constructible_with_allocator_suffix<T, InnerAlloc, Args...>::value ));
|
||||
dispatch_allocator_prefix_suffix
|
||||
( unsigned_< is_constructible_with_allocator_prefix<T, InnerAlloc, Args...>::value ? 1u :
|
||||
(is_constructible_with_std_allocator_prefix<T, InnerAlloc, Args...>::value ? 2u : 0u) >()
|
||||
( bool_< is_constructible_with_allocator_prefix<T, InnerAlloc, Args...>::value>()
|
||||
, outermost_alloc, inner_alloc, p, ::boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@@ -429,7 +395,7 @@ inline void dispatch_uses_allocator
|
||||
template < typename OutermostAlloc, typename InnerAlloc, typename T\
|
||||
BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
|
||||
inline void dispatch_allocator_prefix_suffix\
|
||||
(unsigned_<1u> use_alloc_prefix, OutermostAlloc& outermost_alloc,\
|
||||
(true_type use_alloc_prefix, OutermostAlloc& outermost_alloc,\
|
||||
InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
(void)use_alloc_prefix,\
|
||||
@@ -437,21 +403,10 @@ inline void dispatch_allocator_prefix_suffix\
|
||||
(outermost_alloc, p, allocator_arg, inner_alloc BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
}\
|
||||
\
|
||||
template < typename OutermostAlloc, typename InnerAlloc, typename T\
|
||||
BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
|
||||
inline void dispatch_allocator_prefix_suffix\
|
||||
(unsigned_<2u> use_alloc_prefix, OutermostAlloc& outermost_alloc,\
|
||||
InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
(void)use_alloc_prefix,\
|
||||
allocator_traits<OutermostAlloc>::construct\
|
||||
(outermost_alloc, p, alloc_arg<>::get(), inner_alloc BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
}\
|
||||
\
|
||||
template < typename OutermostAlloc, typename InnerAlloc, typename T\
|
||||
BOOST_MOVE_I##N BOOST_MOVE_CLASS##N >\
|
||||
inline void dispatch_allocator_prefix_suffix\
|
||||
(unsigned_<0u> use_alloc_prefix, OutermostAlloc& outermost_alloc,\
|
||||
(false_type use_alloc_prefix, OutermostAlloc& outermost_alloc,\
|
||||
InnerAlloc& inner_alloc, T* p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
|
||||
{\
|
||||
(void)use_alloc_prefix;\
|
||||
@@ -467,8 +422,7 @@ inline void dispatch_uses_allocator\
|
||||
{\
|
||||
(void)uses_allocator;\
|
||||
dispatch_allocator_prefix_suffix\
|
||||
( unsigned_< is_constructible_with_allocator_prefix<T, InnerAlloc BOOST_MOVE_I##N BOOST_MOVE_TARG##N>::value ? 1u :\
|
||||
(is_constructible_with_std_allocator_prefix<T, InnerAlloc BOOST_MOVE_I##N BOOST_MOVE_TARG##N>::value ? 2u : 0u) >()\
|
||||
( bool_< is_constructible_with_allocator_prefix<T, InnerAlloc BOOST_MOVE_I##N BOOST_MOVE_TARG##N>::value >()\
|
||||
, outermost_alloc, inner_alloc, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
|
||||
}\
|
||||
\
|
||||
|
||||
@@ -35,38 +35,48 @@ namespace boost { namespace container {
|
||||
|
||||
#if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
|
||||
|
||||
template <typename OuterAlloc, typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor;
|
||||
template <typename OuterAlloc, typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor;
|
||||
|
||||
#else // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
|
||||
|
||||
template <typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor;
|
||||
template <typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor;
|
||||
|
||||
template <typename OuterAlloc, typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
|
||||
template <typename OuterAlloc, typename ...InnerAllocs>
|
||||
class scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>;
|
||||
|
||||
#endif // #if !defined(BOOST_CONTAINER_UNIMPLEMENTED_PACK_EXPANSION_TO_FIXED_LIST)
|
||||
|
||||
|
||||
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename OuterAlloc, BOOST_MOVE_CLASSDFLT9>
|
||||
class scoped_allocator_adaptor;
|
||||
template <typename OuterAlloc, BOOST_MOVE_CLASSDFLT9>
|
||||
class scoped_allocator_adaptor;
|
||||
|
||||
#endif
|
||||
|
||||
template <int Dummy = 0>
|
||||
struct std_allocator_arg_holder
|
||||
{
|
||||
static ::std::allocator_arg_t *dummy;
|
||||
};
|
||||
|
||||
template <int Dummy>
|
||||
::std::allocator_arg_t *std_allocator_arg_holder<Dummy>::dummy;
|
||||
|
||||
#else //BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||
|
||||
//! The allocator_arg_t struct is an empty structure type used as a unique type to
|
||||
//! disambiguate constructor and function overloading. Specifically, several types
|
||||
//! have constructors with allocator_arg_t as the first argument, immediately followed
|
||||
//! by an argument of a type that satisfies Allocator requirements
|
||||
struct allocator_arg_t{};
|
||||
typedef const std::allocator_arg_t & allocator_arg_t;
|
||||
|
||||
//! A instance of type allocator_arg_t
|
||||
//!
|
||||
static const allocator_arg_t allocator_arg = allocator_arg_t();
|
||||
static allocator_arg_t allocator_arg = BOOST_CONTAINER_DOC1ST(unspecified, *std_allocator_arg_holder<>::dummy);
|
||||
|
||||
template <class T>
|
||||
struct constructible_with_allocator_suffix;
|
||||
@@ -74,9 +84,6 @@ struct constructible_with_allocator_suffix;
|
||||
template <class T>
|
||||
struct constructible_with_allocator_prefix;
|
||||
|
||||
template <class T>
|
||||
struct constructible_with_std_allocator_prefix;
|
||||
|
||||
template <typename T, typename Allocator>
|
||||
struct uses_allocator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user