Updated to new meta-functions reused from Intrusive/Move

This commit is contained in:
Ion Gaztañaga
2015-04-14 15:21:46 +02:00
parent 64c2e787f7
commit 6477543f3b
20 changed files with 306 additions and 326 deletions

View File

@@ -83,9 +83,9 @@ class adaptive_pool
typedef T * pointer;
typedef const T * const_pointer;
typedef typename ::boost::container::
container_detail::unvoid<T>::type & reference;
typedef const typename ::boost::container::
container_detail::unvoid<T>::type & const_reference;
container_detail::unvoid_ref<T>::type reference;
typedef typename ::boost::container::
container_detail::unvoid_ref<const T>::type const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;

View File

@@ -96,6 +96,10 @@ template<class T>
struct is_std_allocator< std::allocator<T> >
{ static const bool value = true; };
template<class Allocator>
struct is_not_std_allocator
{ static const bool value = !is_std_allocator<Allocator>::value; };
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(pointer)
BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(const_pointer)
BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference)
@@ -195,11 +199,11 @@ struct allocator_traits
const_pointer;
//reference
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
reference, typename container_detail::unvoid<value_type>::type&)
reference, typename container_detail::unvoid_ref<value_type>::type)
reference;
//const_reference
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT(boost::container::container_detail::, Allocator,
const_reference, const typename container_detail::unvoid<value_type>::type&)
const_reference, typename container_detail::unvoid_ref<const value_type>::type)
const_reference;
//void_pointer
typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_EVAL_DEFAULT(boost::container::container_detail::, Allocator,
@@ -340,7 +344,12 @@ struct allocator_traits
template <class T, class ...Args>
static void construct(Allocator & a, T* p, BOOST_FWD_REF(Args)... args)
{
container_detail::bool_<container_detail::is_std_allocator<Allocator>::value> flag;
static const bool value = ::boost::move_detail::and_
< container_detail::is_not_std_allocator<Allocator>
, boost::container::container_detail::has_member_function_callable_with_construct
< Allocator, T*, Args... >
>::value;
container_detail::bool_<value> flag;
allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
}
#endif
@@ -390,26 +399,12 @@ struct allocator_traits
{ return a; }
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class ...Args>
static void priv_construct(container_detail::false_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
{
const bool value = boost::container::container_detail::
has_member_function_callable_with_construct
< Allocator, T*, Args... >::value;
container_detail::bool_<value> flag;
(priv_construct_dispatch_next)(flag, a, p, ::boost::forward<Args>(args)...);
}
template<class T, class ...Args>
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)...); }
template<class T, class ...Args>
static void priv_construct_dispatch_next(container_detail::true_type, Allocator &a, T *p, BOOST_FWD_REF(Args) ...args)
{ a.construct( p, ::boost::forward<Args>(args)...); }
template<class T, class ...Args>
static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args)
static void priv_construct(container_detail::false_type, Allocator &, T *p, BOOST_FWD_REF(Args) ...args)
{ ::new((void*)p, boost_container_new_t()) T(::boost::forward<Args>(args)...); }
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
public:
@@ -418,54 +413,38 @@ struct allocator_traits
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;\
static const bool value = ::boost::move_detail::and_ \
< container_detail::is_not_std_allocator<Allocator> \
, 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)(flag, a, p BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
}\
//
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL)
BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL)
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_CONSTRUCT_IMPL
private:
//////////////////
/////////////////////////////////
// priv_construct
//////////////////
/////////////////////////////////
#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);\
}\
static void priv_construct(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(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); }\
static void priv_construct(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); }\
//
BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL)
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_IMPL
/////////////////////////////////
// priv_construct_dispatch_next
/////////////////////////////////
#define BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL(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); }\
//
BOOST_MOVE_ITERATE_0TO8(BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL)
#undef BOOST_CONTAINER_ALLOCATOR_TRAITS_PRIV_CONSTRUCT_DISPATCH_NEXT_IMPL
#endif // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T>
static void priv_construct_dispatch_next(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&)
static void priv_construct(container_detail::false_type, Allocator &, T *p, const ::boost::container::default_init_t&)
{ ::new((void*)p) T; }
static bool priv_storage_is_unpropagable(container_detail::true_type, const Allocator &a, pointer p)

View File

@@ -835,9 +835,10 @@ class deque : protected deque_base<Allocator>
template <class InIt>
void assign(InIt first, InIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InIt, size_type>::value
&& container_detail::is_input_iterator<InIt>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<InIt, size_type>
, container_detail::is_not_input_iterator<InIt>
>::type * = 0
#endif
)
@@ -857,9 +858,10 @@ class deque : protected deque_base<Allocator>
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class FwdIt>
void assign(FwdIt first, FwdIt last
, typename container_detail::enable_if_c
< !container_detail::is_convertible<FwdIt, size_type>::value
&& !container_detail::is_input_iterator<FwdIt>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<FwdIt, size_type>
, container_detail::is_input_iterator<FwdIt>
>::type * = 0
)
{
@@ -1509,9 +1511,10 @@ class deque : protected deque_base<Allocator>
template <class InIt>
iterator insert(const_iterator pos, InIt first, InIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InIt, size_type>::value
&& container_detail::is_input_iterator<InIt>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<InIt, size_type>
, container_detail::is_not_input_iterator<InIt>
>::type * = 0
#endif
)
@@ -1545,9 +1548,10 @@ class deque : protected deque_base<Allocator>
template <class FwdIt>
iterator insert(const_iterator p, FwdIt first, FwdIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<FwdIt, size_type>::value
&& !container_detail::is_input_iterator<FwdIt>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<FwdIt, size_type>
, container_detail::is_input_iterator<FwdIt>
>::type * = 0
#endif
)

View File

@@ -123,48 +123,49 @@ struct are_elements_contiguous< ::boost::interprocess::offset_ptr<PointedType, D
template <typename I, typename O>
struct are_contiguous_and_same
{
static const bool is_same_io =
is_same< typename remove_const< typename ::boost::container::iterator_traits<I>::value_type >::type
, typename ::boost::container::iterator_traits<O>::value_type
>::value;
static const bool value = is_same_io &&
are_elements_contiguous<I>::value &&
are_elements_contiguous<O>::value;
};
: boost::move_detail::and_
< are_elements_contiguous<I>
, are_elements_contiguous<O>
, is_same< typename remove_const< typename ::boost::container::iterator_traits<I>::value_type >::type
, typename ::boost::container::iterator_traits<O>::value_type
>
>
{};
template <typename I, typename O>
struct is_memtransfer_copy_assignable
{
static const bool value = are_contiguous_and_same<I, O>::value &&
container_detail::is_trivially_copy_assignable< typename ::boost::container::iterator_traits<I>::value_type >::value;
};
: boost::move_detail::and_
< are_contiguous_and_same<I, O>
, container_detail::is_trivially_copy_assignable< typename ::boost::container::iterator_traits<I>::value_type >
>
{};
template <typename I, typename O>
struct is_memtransfer_copy_constructible
{
static const bool value = are_contiguous_and_same<I, O>::value &&
container_detail::is_trivially_copy_constructible< typename ::boost::container::iterator_traits<I>::value_type >::value;
};
: boost::move_detail::and_
< are_contiguous_and_same<I, O>
, container_detail::is_trivially_copy_constructible< typename ::boost::container::iterator_traits<I>::value_type >
>
{};
template <typename I, typename O, typename R>
struct enable_if_memtransfer_copy_constructible
: enable_if_c<container_detail::is_memtransfer_copy_constructible<I, O>::value, R>
: enable_if<container_detail::is_memtransfer_copy_constructible<I, O>, R>
{};
template <typename I, typename O, typename R>
struct disable_if_memtransfer_copy_constructible
: enable_if_c<!container_detail::is_memtransfer_copy_constructible<I, O>::value, R>
: disable_if<container_detail::is_memtransfer_copy_constructible<I, O>, R>
{};
template <typename I, typename O, typename R>
struct enable_if_memtransfer_copy_assignable
: enable_if_c<container_detail::is_memtransfer_copy_assignable<I, O>::value, R>
: enable_if<container_detail::is_memtransfer_copy_assignable<I, O>, R>
{};
template <typename I, typename O, typename R>
struct disable_if_memtransfer_copy_assignable
: enable_if_c<!container_detail::is_memtransfer_copy_assignable<I, O>::value, R>
: disable_if<container_detail::is_memtransfer_copy_assignable<I, O>, R>
{};
template

View File

@@ -32,6 +32,7 @@ using ::boost::intrusive::iterator_advance;
using ::boost::intrusive::iterator;
using ::boost::intrusive::iterator_enable_if_tag;
using ::boost::intrusive::iterator_disable_if_tag;
using ::boost::intrusive::iterator_arrow_result;
} //namespace container {
} //namespace boost {

View File

@@ -651,11 +651,13 @@ namespace container_detail {
template<class T>
struct has_iterator_category
{
struct two { char _[2]; };
template <typename X>
static char test(int, typename X::iterator_category*);
template <typename X>
static int test(int, ...);
static two test(int, ...);
static const bool value = (1 == sizeof(test<T>(0, 0)));
};
@@ -673,6 +675,12 @@ struct is_input_iterator<T, false>
static const bool value = false;
};
template<class T>
struct is_not_input_iterator
{
static const bool value = !is_input_iterator<T>::value;
};
template<class T, bool = has_iterator_category<T>::value >
struct is_forward_iterator
{
@@ -796,7 +804,7 @@ class iterator_from_iiterator
{ return !(l == r); }
reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW
{ return (*this->m_iit).get_data(); }
{ return this->m_iit->get_data(); }
pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW
{ return ::boost::intrusive::pointer_traits<pointer>::pointer_to(this->operator*()); }

View File

@@ -23,6 +23,8 @@
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
#include <boost/move/detail/type_traits.hpp>
#include <boost/intrusive/detail/mpl.hpp>
#include <cstddef>
@@ -30,110 +32,35 @@ namespace boost {
namespace container {
namespace container_detail {
template <class T, T val>
struct integral_constant
{
static const T value = val;
typedef integral_constant<T,val> type;
};
template< bool C_ >
struct bool_ : integral_constant<bool, C_>
{
static const bool value = C_;
operator bool() const { return bool_::value; }
};
template< unsigned V_ >
struct unsigned_ : integral_constant<unsigned, V_>
{
static const unsigned value = V_;
operator unsigned() const { return unsigned_::value; }
};
typedef bool_<true> true_;
typedef bool_<false> false_;
typedef true_ true_type;
typedef false_ false_type;
typedef char yes_type;
struct no_type
{
char padding[8];
};
template <bool B, class T = void>
struct enable_if_c {
typedef T type;
};
template <class T>
struct enable_if_c<false, T> {};
template <class Cond, class T = void>
struct enable_if : public enable_if_c<Cond::value, T> {};
template <class Cond, class T = void>
struct disable_if : public enable_if_c<!Cond::value, T> {};
template <bool B, class T = void>
struct disable_if_c : public enable_if_c<!B, T> {};
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
template <class T, class U>
struct is_convertible
{
static const bool value = __is_convertible_to(T, U);
};
#else
template <class T, class U>
class is_convertible
{
typedef char true_t;
class false_t { char dummy[2]; };
//use any_conversion as first parameter since in MSVC
//overaligned types can't go through ellipsis
static false_t dispatch(...);
static true_t dispatch(U);
static T &trigger();
public:
static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
};
#endif
template<
bool C
, typename T1
, typename T2
>
struct if_c
{
typedef T1 type;
};
template<
typename T1
, typename T2
>
struct if_c<false,T1,T2>
{
typedef T2 type;
};
template<
typename T1
, typename T2
, typename T3
>
struct if_
{
typedef typename if_c<0 != T1::value, T2, T3>::type type;
};
using boost::move_detail::integral_constant;
using boost::move_detail::true_type;
using boost::move_detail::false_type;
using boost::move_detail::enable_if_c;
using boost::move_detail::enable_if;
using boost::move_detail::enable_if_convertible;
using boost::move_detail::disable_if_c;
using boost::move_detail::disable_if;
using boost::move_detail::disable_if_convertible;
using boost::move_detail::is_convertible;
using boost::move_detail::if_c;
using boost::move_detail::if_;
using boost::move_detail::identity;
using boost::move_detail::bool_;
using boost::move_detail::true_;
using boost::move_detail::false_;
using boost::move_detail::yes_type;
using boost::move_detail::no_type;
using boost::move_detail::bool_;
using boost::move_detail::true_;
using boost::move_detail::false_;
using boost::move_detail::unvoid_ref;
using boost::move_detail::and_;
using boost::move_detail::or_;
using boost::move_detail::not_;
using boost::move_detail::enable_if_and;
using boost::move_detail::disable_if_and;
using boost::move_detail::enable_if_or;
using boost::move_detail::disable_if_or;
template <class Pair>
@@ -150,46 +77,6 @@ struct select1st
{ return x; }
};
// identity is an extension: it is not part of the standard.
template <class T>
struct identity
{
typedef T argument_type;
typedef T result_type;
typedef T type;
const T& operator()(const T& x) const
{ return x; }
};
template<std::size_t S>
struct ls_zeros
{
static const std::size_t value = (S & std::size_t(1)) ? 0 : (1u + ls_zeros<(S >> 1u)>::value);
};
template<>
struct ls_zeros<0>
{
static const std::size_t value = 0;
};
template<>
struct ls_zeros<1>
{
static const std::size_t value = 0;
};
template <std::size_t OrigSize, std::size_t RoundTo>
struct ct_rounded_size
{
static const std::size_t value = ((OrigSize-1)/RoundTo+1)*RoundTo;
};
template <typename T> struct unvoid { typedef T type; };
template <> struct unvoid<void> { struct type { }; };
template <> struct unvoid<const void> { struct type { }; };
} //namespace container_detail {
} //namespace container {
} //namespace boost {

View File

@@ -375,7 +375,7 @@ struct node_alloc_holder
{}
NodePtr operator()(const Node &other) const
{ return m_holder.create_node(other.get_data()); }
{ return m_holder.create_node(other.m_data); }
node_alloc_holder &m_holder;
};
@@ -387,7 +387,9 @@ struct node_alloc_holder
{}
NodePtr operator()(Node &other)
{ return m_holder.create_node(::boost::move(other.get_data())); }
{ //Use m_data instead of get_data to allow moving const key in [multi]map
return m_holder.create_node(::boost::move(other.m_data));
}
node_alloc_holder &m_holder;
};

View File

@@ -33,6 +33,46 @@
#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
#include <boost/move/utility_core.hpp>
/*
namespace boost{
template<class T1, class T2>
inline rv< std::pair<T1, T2> > &move(std::pair<T1, T2> &r)
{
return reinterpret_cast< rv< std::pair<T1, T2> > &>(r);
}
template<class T1, class T2>
inline rv< std::pair<T1, T2> > &move(rv< std::pair<T1, T2> > &r)
{
return r;
}
template <class T>
inline typename ::boost::move_detail::enable_if_and
< T &
, boost::container::container_detail::is_std_pair<T>
, ::boost::move_detail::is_rv<T>
>::type
forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
{
return const_cast<T&>(x);
}
template <class T>
inline typename ::boost::move_detail::enable_if_and
< const T &
, boost::container::container_detail::is_std_pair<T>
, ::boost::move_detail::is_not_rv<T>
>::type
forward(const typename ::boost::move_detail::identity<T>::type &x) BOOST_NOEXCEPT
{
return x;
}
} //namespace boost {
*/
namespace boost {
namespace container {
namespace container_detail {
@@ -58,6 +98,24 @@ struct is_pair< std::pair<T1, T2> >
static const bool value = true;
};
template <class T>
struct is_not_pair
{
static const bool value = !is_pair<T>::value;
};
template <class T>
struct is_std_pair
{
static const bool value = false;
};
template <class T1, class T2>
struct is_std_pair< std::pair<T1, T2> >
{
static const bool value = true;
};
struct pair_nat;
struct piecewise_construct_t { };
@@ -182,10 +240,11 @@ struct pair
}
template <class D, class S>
typename ::boost::container::container_detail::enable_if_c
< !(::boost::container::container_detail::is_same<T1, D>::value &&
::boost::container::container_detail::is_same<T2, S>::value)
, pair &>::type
typename ::boost::container::container_detail::disable_if_or
< pair &
, ::boost::container::container_detail::is_same<T1, D>
, ::boost::container::container_detail::is_same<T2, S>
>::type
operator=(const pair<D, S>&p)
{
first = p.first;
@@ -194,18 +253,18 @@ struct pair
}
template <class D, class S>
typename ::boost::container::container_detail::enable_if_c
< !(::boost::container::container_detail::is_same<T1, D>::value &&
::boost::container::container_detail::is_same<T2, S>::value)
, pair &>::type
typename ::boost::container::container_detail::disable_if_or
< pair &
, ::boost::container::container_detail::is_same<T1, D>
, ::boost::container::container_detail::is_same<T2, S>
>::type
operator=(BOOST_RV_REF_BEG pair<D, S> BOOST_RV_REF_END p)
{
first = ::boost::move(p.first);
second = ::boost::move(p.second);
return *this;
}
//std::pair copy assignment
//std::pair copy assignment
pair& operator=(const std::pair<T1, T2> &p)
{
first = p.first;

View File

@@ -52,6 +52,10 @@
// other
#include <boost/core/no_exceptions_support.hpp>
#include <boost/container/detail/std_fwd.hpp>
namespace boost {
namespace container {
namespace container_detail {
@@ -156,7 +160,7 @@ struct tree_internal_data_type
template<class T1, class T2>
struct tree_internal_data_type< std::pair<T1, T2> >
{
typedef pair<T1, T2> type;
typedef pair<typename boost::move_detail::remove_const<T1>::type, T2> type;
};
//The node to be store in the tree
@@ -549,9 +553,10 @@ class tree
tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
const allocator_type& a
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< container_detail::is_input_iterator<InputIterator>::value
|| container_detail::is_same<alloc_version, version_1>::value
, typename container_detail::enable_if_or
< void
, container_detail::is_same<alloc_version, version_1>
, container_detail::is_input_iterator<InputIterator>
>::type * = 0
#endif
)
@@ -577,9 +582,10 @@ class tree
tree(bool unique_insertion, InputIterator first, InputIterator last, const key_compare& comp,
const allocator_type& a
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !(container_detail::is_input_iterator<InputIterator>::value
|| container_detail::is_same<alloc_version, version_1>::value)
, typename container_detail::disable_if_or
< void
, container_detail::is_same<alloc_version, version_1>
, container_detail::is_input_iterator<InputIterator>
>::type * = 0
#endif
)
@@ -606,10 +612,11 @@ class tree
tree( ordered_range_t, InputIterator first, InputIterator last
, const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< container_detail::is_input_iterator<InputIterator>::value
|| container_detail::is_same<alloc_version, version_1>::value
>::type * = 0
, typename container_detail::enable_if_or
< void
, container_detail::is_same<alloc_version, version_1>
, container_detail::is_input_iterator<InputIterator>
>::type * = 0
#endif
)
: AllocHolder(value_compare(comp), a)
@@ -623,10 +630,11 @@ class tree
tree( ordered_range_t, InputIterator first, InputIterator last
, const key_compare& comp = key_compare(), const allocator_type& a = allocator_type()
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !(container_detail::is_input_iterator<InputIterator>::value
|| container_detail::is_same<alloc_version, version_1>::value)
>::type * = 0
, typename container_detail::disable_if_or
< void
, container_detail::is_same<alloc_version, version_1>
, container_detail::is_input_iterator<InputIterator>
>::type * = 0
#endif
)
: AllocHolder(value_compare(comp), a)

View File

@@ -31,6 +31,7 @@ namespace container {
namespace container_detail {
using ::boost::move_detail::is_same;
using ::boost::move_detail::is_different;
using ::boost::move_detail::is_pointer;
using ::boost::move_detail::add_reference;
using ::boost::move_detail::add_const;

View File

@@ -417,9 +417,7 @@ class list
template <class InpIt>
void assign(InpIt first, InpIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InpIt, size_type>::value
>::type * = 0
, typename container_detail::disable_if_convertible<InpIt, size_type>::type * = 0
#endif
)
{

View File

@@ -74,9 +74,9 @@ class node_allocator
typedef T * pointer;
typedef const T * const_pointer;
typedef typename ::boost::container::
container_detail::unvoid<T>::type & reference;
typedef const typename ::boost::container::
container_detail::unvoid<T>::type & const_reference;
container_detail::unvoid_ref<T>::type reference;
typedef typename ::boost::container::
container_detail::unvoid_ref<const T>::type const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;

View File

@@ -1129,7 +1129,7 @@ class scoped_allocator_adaptor
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
void
#else
typename container_detail::enable_if_c<!container_detail::is_pair<T>::value, void>::type
typename container_detail::enable_if<container_detail::is_not_pair<T> >::type
#endif
construct(T* p, BOOST_FWD_REF(Args)...args)
{
@@ -1146,7 +1146,7 @@ class scoped_allocator_adaptor
//overload selection problems when the first parameter is a pair.
#define BOOST_CONTAINER_SCOPED_ALLOCATOR_CONSTRUCT_CODE(N) \
template < typename T BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
typename container_detail::enable_if_c<!container_detail::is_pair<T>::value, void>::type\
typename container_detail::enable_if< container_detail::is_not_pair<T> >::type\
construct(T* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
{\
container_detail::dispatch_uses_allocator\
@@ -1188,12 +1188,12 @@ class scoped_allocator_adaptor
template <class T1, class T2, class U, class V>
void construct( std::pair<T1, T2>* p
, BOOST_RV_REF_BEG std::pair<U, V> BOOST_RV_REF_END x)
{ this->construct_pair(p, x); }
{ this->construct_pair(p, ::boost::move(x)); }
template <class T1, class T2, class U, class V>
void construct( container_detail::pair<T1, T2>* p
, BOOST_RV_REF_BEG container_detail::pair<U, V> BOOST_RV_REF_END x)
{ this->construct_pair(p, x); }
{ this->construct_pair(p, ::boost::move(x)); }
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
@@ -1246,6 +1246,39 @@ class scoped_allocator_adaptor
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
};
template<bool ZeroInner>
struct scoped_allocator_operator_equal
{
//Optimize equal outer allocator types with
//allocator_traits::equal which uses is_always_equal
template<class IA>
static bool equal_outer(const IA &l, const IA &r)
{ return allocator_traits<IA>::equal(l, r); }
//Otherwise compare it normally
template<class IA1, class IA2>
static bool equal_outer(const IA1 &l, const IA2 &r)
{ return l == r; }
//Otherwise compare it normally
template<class IA>
static bool equal_inner(const IA &l, const IA &r)
{ return allocator_traits<IA>::equal(l, r); }
};
template<>
struct scoped_allocator_operator_equal<true>
: scoped_allocator_operator_equal<false>
{
//when inner allocator count is zero,
//inner_allocator_type is the same as outer_allocator_type
//so both types can be different in operator==
template<class IA1, class IA2>
static bool equal_inner(const IA1 &, const IA2 &)
{ return true; }
};
template <typename OuterA1, typename OuterA2, BOOST_CONTAINER_SCOPEDALLOC_ALLINNERCLASS>
inline bool operator==(const scoped_allocator_adaptor<OuterA1, BOOST_CONTAINER_SCOPEDALLOC_ALLINNER>& a
,const scoped_allocator_adaptor<OuterA2, BOOST_CONTAINER_SCOPEDALLOC_ALLINNER>& b)
@@ -1255,14 +1288,9 @@ inline bool operator==(const scoped_allocator_adaptor<OuterA1, BOOST_CONTAINER_S
#else
const bool has_zero_inner = boost::container::container_detail::is_same<P0, void>::value;
#endif
typedef typename scoped_allocator_adaptor<OuterA1, BOOST_CONTAINER_SCOPEDALLOC_ALLINNER>
::outer_allocator_type outer_allocator_type;
typedef typename scoped_allocator_adaptor<OuterA1, BOOST_CONTAINER_SCOPEDALLOC_ALLINNER>
::inner_allocator_type inner_allocator_type;
return allocator_traits<outer_allocator_type>::equal(a.outer_allocator(), b.outer_allocator())
&& (has_zero_inner ||
allocator_traits<inner_allocator_type>::equal(a.inner_allocator(), b.inner_allocator()));
typedef scoped_allocator_operator_equal<has_zero_inner> equal_t;
return equal_t::equal_outer(a.outer_allocator(), b.outer_allocator()) &&
equal_t::equal_inner(a.inner_allocator(), b.inner_allocator());
}
template <typename OuterA1, typename OuterA2, BOOST_CONTAINER_SCOPEDALLOC_ALLINNERCLASS>

View File

@@ -442,9 +442,7 @@ class slist
template <class InpIt>
void assign(InpIt first, InpIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InpIt, size_type>::value
>::type * = 0
, typename container_detail::disable_if_convertible<InpIt, size_type>::type * = 0
#endif
)
{

View File

@@ -311,8 +311,12 @@ class small_vector_base
: public vector<T, small_vector_allocator<SecondaryAllocator> >
{
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
//Make it public as it will be inherited by small_vector and container
//must have this public member
typedef typename allocator_traits<SecondaryAllocator>::pointer pointer;
private:
BOOST_COPYABLE_AND_MOVABLE(small_vector_base)
friend class small_vector_allocator<SecondaryAllocator>;

View File

@@ -349,7 +349,7 @@ class stable_vector_iterator
return tmp;
}
friend difference_type operator-(const stable_vector_iterator& left, const stable_vector_iterator& right) BOOST_NOEXCEPT_OR_NOTHROW
friend difference_type operator-(const stable_vector_iterator &left, const stable_vector_iterator &right) BOOST_NOEXCEPT_OR_NOTHROW
{ return left.m_pn->up - right.m_pn->up; }
//Comparison operators
@@ -493,7 +493,7 @@ class stable_vector
, false> iterator_impl;
typedef stable_vector_iterator
< typename allocator_traits<Allocator>::pointer
, false> const_iterator_impl;
, true> const_iterator_impl;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
@@ -850,13 +850,12 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to n.
template<typename InputIterator>
void assign(InputIterator first,InputIterator last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InputIterator, size_type>::value
>::type * = 0
#endif
)
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
typename container_detail::disable_if_convertible<InputIterator, size_type>::type
#else
void
#endif
assign(InputIterator first,InputIterator last)
{
STABLE_VECTOR_CHECK_INVARIANT;
iterator first1 = this->begin();
@@ -1517,14 +1516,16 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to distance [first, last).
template <class InputIterator>
iterator insert(const_iterator p, InputIterator first, InputIterator last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InputIterator, size_type>::value
&& container_detail::is_input_iterator<InputIterator>::value
>::type * = 0
#endif
)
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
typename container_detail::disable_if_or
< iterator
, container_detail::is_convertible<InputIterator, size_type>
, container_detail::is_not_input_iterator<InputIterator>
>::type
#else
iterator
#endif
insert(const_iterator p, InputIterator first, InputIterator last)
{
STABLE_VECTOR_CHECK_INVARIANT;
const size_type pos_n = p - this->cbegin();
@@ -1536,12 +1537,12 @@ class stable_vector
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class FwdIt>
iterator insert(const_iterator p, FwdIt first, FwdIt last
, typename container_detail::enable_if_c
< !container_detail::is_convertible<FwdIt, size_type>::value
&& !container_detail::is_input_iterator<FwdIt>::value
>::type * = 0
)
typename container_detail::disable_if_or
< iterator
, container_detail::is_convertible<FwdIt, size_type>
, container_detail::is_input_iterator<FwdIt>
>::type
insert(const_iterator p, FwdIt first, FwdIt last)
{
const size_type num_new = static_cast<size_type>(boost::container::iterator_distance(first, last));
const size_type idx = static_cast<size_type>(p - this->cbegin());

View File

@@ -165,8 +165,7 @@ class basic_string_base
static const size_type MinInternalBufferChars = 8;
static const size_type AlignmentOfValueType =
alignment_of<value_type>::value;
static const size_type ShortDataOffset =
container_detail::ct_rounded_size<sizeof(short_header), AlignmentOfValueType>::value;
static const size_type ShortDataOffset = ((sizeof(short_header)-1)/AlignmentOfValueType+1)*AlignmentOfValueType;
static const size_type ZeroCostInternalBufferChars =
(sizeof(long_t) - ShortDataOffset)/sizeof(value_type);
static const size_type UnalignedFinalInternalBufferChars =
@@ -1289,9 +1288,7 @@ class basic_string
template <class InputIter>
basic_string& assign(InputIter first, InputIter last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InputIter, size_type>::value
>::type * = 0
, typename container_detail::disable_if_convertible<InputIter, size_type>::type * = 0
#endif
)
{
@@ -1438,9 +1435,10 @@ class basic_string
template <class InputIter>
iterator insert(const_iterator p, InputIter first, InputIter last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InputIter, size_type>::value
&& container_detail::is_input_iterator<InputIter>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<InputIter, size_type>
, container_detail::is_not_input_iterator<InputIter>
>::type * = 0
#endif
)
@@ -1455,9 +1453,10 @@ class basic_string
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class ForwardIter>
iterator insert(const_iterator p, ForwardIter first, ForwardIter last
, typename container_detail::enable_if_c
< !container_detail::is_convertible<ForwardIter, size_type>::value
&& !container_detail::is_input_iterator<ForwardIter>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<ForwardIter, size_type>
, container_detail::is_input_iterator<ForwardIter>
>::type * = 0
)
{
@@ -1829,9 +1828,10 @@ class basic_string
template <class InputIter>
basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
, typename container_detail::enable_if_c
< !container_detail::is_convertible<InputIter, size_type>::value
&& container_detail::is_input_iterator<InputIter>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<InputIter, size_type>
, container_detail::is_input_iterator<InputIter>
>::type * = 0
#endif
)
@@ -1850,9 +1850,10 @@ class basic_string
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
template <class ForwardIter>
basic_string& replace(const_iterator i1, const_iterator i2, ForwardIter j1, ForwardIter j2
, typename container_detail::enable_if_c
< !container_detail::is_convertible<ForwardIter, size_type>::value
&& !container_detail::is_input_iterator<ForwardIter>::value
, typename container_detail::disable_if_or
< void
, container_detail::is_convertible<ForwardIter, size_type>
, container_detail::is_not_input_iterator<ForwardIter>
>::type * = 0
)
{

View File

@@ -105,10 +105,10 @@ class ComplexAllocator
typedef T value_type;
typedef SimpleSmartPtr<T> pointer;
typedef SimpleSmartPtr<const T> const_pointer;
typedef typename boost::container::
container_detail::unvoid<T>::type & reference;
typedef const typename boost::container::
container_detail::unvoid<T>::type & const_reference;
typedef typename ::boost::container::
container_detail::unvoid_ref<T>::type reference;
typedef typename ::boost::container::
container_detail::unvoid_ref<const T>::type const_reference;
typedef SimpleSmartPtr<void> void_pointer;
typedef SimpleSmartPtr<const void> const_void_pointer;
typedef signed short difference_type;

View File

@@ -86,10 +86,10 @@ class dummy_test_allocator
typedef T value_type;
typedef T * pointer;
typedef const T * const_pointer;
typedef typename container_detail::add_reference
<value_type>::type reference;
typedef typename container_detail::add_reference
<const value_type>::type const_reference;
typedef typename container_detail::
unvoid_ref<value_type>::type reference;
typedef typename container_detail::
unvoid_ref<const value_type>::type const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;