summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2014-10-19 20:22:58 (GMT)
committerTobias Markmann <tm@ayena.de>2014-10-20 13:49:33 (GMT)
commit6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch)
tree2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/unordered/detail/allocate.hpp
parent38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff)
downloadswift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip
swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0. Updated our update.sh script to stop on error. Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to missing include of <iostream> with newer Boost. Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/unordered/detail/allocate.hpp')
-rw-r--r--3rdParty/Boost/src/boost/unordered/detail/allocate.hpp285
1 files changed, 86 insertions, 199 deletions
diff --git a/3rdParty/Boost/src/boost/unordered/detail/allocate.hpp b/3rdParty/Boost/src/boost/unordered/detail/allocate.hpp
index b6f1c79..4c20b16 100644
--- a/3rdParty/Boost/src/boost/unordered/detail/allocate.hpp
+++ b/3rdParty/Boost/src/boost/unordered/detail/allocate.hpp
@@ -9,8 +9,9 @@
#ifndef BOOST_UNORDERED_ALLOCATE_HPP
#define BOOST_UNORDERED_ALLOCATE_HPP
-#if defined(_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
+#include <boost/config.hpp>
+#if defined(BOOST_HAS_PRAGMA_ONCE)
+#pragma once
#endif
#include <boost/unordered/detail/fwd.hpp>
@@ -85,7 +86,7 @@ namespace boost { namespace unordered { namespace detail {
// Either forwarding variadic arguments, or storing the arguments in
// emplace_args##n
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args
#define BOOST_UNORDERED_EMPLACE_ARGS BOOST_FWD_REF(Args)... args
@@ -136,7 +137,7 @@ namespace boost { namespace unordered { namespace detail {
#define BOOST_UNORDERED_EMPLACE_ARGS2 create_emplace_args
#define BOOST_UNORDERED_EMPLACE_ARGS3 create_emplace_args
-#if defined(BOOST_NO_RVALUE_REFERENCES)
+#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#define BOOST_UNORDERED_EARGS_MEMBER(z, n, _) \
typedef BOOST_FWD_REF(BOOST_PP_CAT(A, n)) BOOST_PP_CAT(Arg, n); \
@@ -234,9 +235,11 @@ namespace boost { namespace unordered { namespace detail {
#pragma warning(disable:4100) // unreferenced formal parameter
#endif
- template <class T>
- inline void destroy(T* x) {
- x->~T();
+ namespace func {
+ template <class T>
+ inline void destroy(T* x) {
+ x->~T();
+ }
}
#if defined(BOOST_MSVC)
@@ -257,13 +260,12 @@ namespace boost { namespace unordered { namespace detail {
template <typename T, unsigned int> struct expr_test;
template <typename T> struct expr_test<T, sizeof(char)> : T {};
- template <typename U> static char for_expr_test(U const&);
# define BOOST_UNORDERED_CHECK_EXPRESSION(count, result, expression) \
template <typename U> \
static typename boost::unordered::detail::expr_test< \
BOOST_PP_CAT(choice, result), \
- sizeof(boost::unordered::detail::for_expr_test(( \
+ sizeof(for_expr_test(( \
(expression), \
0)))>::type test( \
BOOST_PP_CAT(choice, count))
@@ -276,6 +278,7 @@ namespace boost { namespace unordered { namespace detail {
# define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \
struct BOOST_PP_CAT(has_, name) \
{ \
+ template <typename U> static char for_expr_test(U const&); \
BOOST_UNORDERED_CHECK_EXPRESSION(1, 1, \
boost::unordered::detail::make< thing >().name args); \
BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \
@@ -342,7 +345,7 @@ namespace boost { namespace unordered { namespace detail {
# include <boost/type_traits/is_same.hpp>
# endif
-# if !defined(BOOST_NO_VARIADIC_TEMPLATES) && \
+# if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_SFINAE_EXPR)
# define BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT 1
# else
@@ -432,7 +435,7 @@ namespace boost { namespace unordered { namespace detail {
max_size, U const, (), 0
);
-# if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+# if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename T, typename ValueType, typename... Args>
BOOST_UNORDERED_HAS_FUNCTION(
@@ -473,6 +476,9 @@ namespace boost { namespace unordered { namespace detail {
# endif
+ namespace func
+ {
+
template <typename Alloc>
inline Alloc call_select_on_container_copy_construction(const Alloc& rhs,
typename boost::enable_if_c<
@@ -510,6 +516,8 @@ namespace boost { namespace unordered { namespace detail {
return (std::numeric_limits<SizeType>::max)();
}
+ } // namespace func.
+
template <typename Alloc>
struct allocator_traits
{
@@ -589,7 +597,7 @@ namespace boost { namespace unordered { namespace detail {
boost::unordered::detail::has_destroy<Alloc, T>::value>::type
destroy(Alloc&, T* p)
{
- boost::unordered::detail::destroy(p);
+ boost::unordered::detail::func::destroy(p);
}
# elif !defined(BOOST_NO_SFINAE_EXPR)
@@ -623,7 +631,7 @@ namespace boost { namespace unordered { namespace detail {
boost::unordered::detail::has_destroy<Alloc, T>::value>::type
destroy(Alloc&, T* p)
{
- boost::unordered::detail::destroy(p);
+ boost::unordered::detail::func::destroy(p);
}
# else
@@ -669,21 +677,22 @@ namespace boost { namespace unordered { namespace detail {
boost::is_same<T, value_type>::value,
void*>::type = 0)
{
- boost::unordered::detail::destroy(p);
+ boost::unordered::detail::func::destroy(p);
}
# endif
static size_type max_size(const Alloc& a)
{
- return boost::unordered::detail::call_max_size<size_type>(a);
+ return boost::unordered::detail::func::
+ call_max_size<size_type>(a);
}
// Allocator propagation on construction
static Alloc select_on_container_copy_construction(Alloc const& rhs)
{
- return boost::unordered::detail::
+ return boost::unordered::detail::func::
call_select_on_container_copy_construction(rhs);
}
@@ -758,12 +767,12 @@ namespace boost { namespace unordered { namespace detail {
#endif
-namespace boost { namespace unordered { namespace detail {
+namespace boost { namespace unordered { namespace detail { namespace func {
////////////////////////////////////////////////////////////////////////////
// call_construct
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
# if BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT
@@ -792,7 +801,7 @@ namespace boost { namespace unordered { namespace detail {
template <typename Alloc, typename T>
inline void destroy_value_impl(Alloc&, T* x) {
- boost::unordered::detail::destroy(x);
+ boost::unordered::detail::func::destroy(x);
}
@@ -802,7 +811,7 @@ namespace boost { namespace unordered { namespace detail {
template <typename Alloc, typename T>
inline void destroy_value_impl(Alloc&, T* x) {
- boost::unordered::detail::destroy(x);
+ boost::unordered::detail::func::destroy(x);
}
#endif
@@ -812,13 +821,13 @@ namespace boost { namespace unordered { namespace detail {
//
// Used for piecewise construction.
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
# define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \
template<typename Alloc, typename T> \
void construct_from_tuple(Alloc& alloc, T* ptr, namespace_ tuple<>) \
{ \
- boost::unordered::detail::call_construct(alloc, ptr); \
+ boost::unordered::detail::func::call_construct(alloc, ptr); \
} \
\
BOOST_PP_REPEAT_FROM_TO(1, n, \
@@ -830,7 +839,7 @@ namespace boost { namespace unordered { namespace detail {
void construct_from_tuple(Alloc& alloc, T* ptr, \
namespace_ tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x) \
{ \
- boost::unordered::detail::call_construct(alloc, ptr, \
+ boost::unordered::detail::func::call_construct(alloc, ptr, \
BOOST_PP_ENUM_##z(n, BOOST_UNORDERED_GET_TUPLE_ARG, namespace_) \
); \
}
@@ -871,7 +880,7 @@ namespace boost { namespace unordered { namespace detail {
# define BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(n, namespace_) \
template<typename Alloc, typename T> \
void construct_from_tuple_impl( \
- boost::unordered::detail::length<0>, Alloc&, T* ptr, \
+ boost::unordered::detail::func::length<0>, Alloc&, T* ptr, \
namespace_ tuple<>) \
{ \
new ((void*) ptr) T(); \
@@ -884,7 +893,7 @@ namespace boost { namespace unordered { namespace detail {
template<typename Alloc, typename T, \
BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
void construct_from_tuple_impl( \
- boost::unordered::detail::length<n>, Alloc&, T* ptr, \
+ boost::unordered::detail::func::length<n>, Alloc&, T* ptr, \
namespace_ tuple<BOOST_PP_ENUM_PARAMS_Z(z, n, A)> const& x) \
{ \
new ((void*) ptr) T( \
@@ -913,7 +922,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
void construct_from_tuple(Alloc& alloc, T* ptr, Tuple const& x)
{
construct_from_tuple_impl(
- boost::unordered::detail::length<
+ boost::unordered::detail::func::length<
boost::tuples::length<Tuple>::value>(),
alloc, ptr, x);
}
@@ -921,146 +930,58 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
#endif
////////////////////////////////////////////////////////////////////////////
- // SFINAE traits for construction.
-
- // Decide which construction method to use for a three argument
- // call. Note that this is difficult to do using overloads because
- // the arguments are packed into 'emplace_args3'.
- //
- // The decision is made on the first argument.
-
-
-#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
- template <typename A, typename B, typename A0>
- struct emulation1 {
- static choice1::type test(choice1, std::pair<A, B> const&);
- static choice2::type test(choice2, A const&);
- static choice3::type test(choice3, convert_from_anything const&);
-
- enum { value =
- sizeof(test(choose(), boost::unordered::detail::make<A0>())) ==
- sizeof(choice2::type) };
- };
-#endif
+ // Trait to check for piecewise construction.
- template <typename A, typename B, typename A0>
- struct check3_base {
+ template <typename A0>
+ struct use_piecewise {
static choice1::type test(choice1,
boost::unordered::piecewise_construct_t);
-#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
- static choice2::type test(choice2, A const&);
-#endif
-
- static choice3::type test(choice3, ...);
+ static choice2::type test(choice2, ...);
- enum { value =
+ enum { value = sizeof(choice1::type) ==
sizeof(test(choose(), boost::unordered::detail::make<A0>())) };
};
- template <typename A, typename B, typename A0>
- struct piecewise3 {
- enum { value = check3_base<A,B,A0>::value == sizeof(choice1::type) };
- };
-
-#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
- template <typename A, typename B, typename A0>
- struct emulation3 {
- enum { value = check3_base<A,B,A0>::value == sizeof(choice2::type) };
- };
-
-#endif
-
-// TODO: Full construct?
-#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
////////////////////////////////////////////////////////////////////////////
// Construct from variadic parameters
+ // For the standard pair constructor.
+
template <typename Alloc, typename T, typename... Args>
inline void construct_value_impl(Alloc& alloc, T* address,
BOOST_FWD_REF(Args)... args)
{
- boost::unordered::detail::call_construct(alloc,
+ boost::unordered::detail::func::call_construct(alloc,
address, boost::forward<Args>(args)...);
}
+ // Special case for piece_construct
+ //
+ // TODO: When possible, it might be better to use std::pair's
+ // constructor for std::piece_construct with std::tuple.
+
template <typename Alloc, typename A, typename B,
typename A0, typename A1, typename A2>
- inline typename enable_if<piecewise3<A, B, A0>, void>::type
+ inline typename enable_if<use_piecewise<A0>, void>::type
construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
BOOST_FWD_REF(A0), BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
{
- boost::unordered::detail::construct_from_tuple(alloc,
+ boost::unordered::detail::func::construct_from_tuple(alloc,
boost::addressof(address->first), boost::forward<A1>(a1));
- boost::unordered::detail::construct_from_tuple(alloc,
+ boost::unordered::detail::func::construct_from_tuple(alloc,
boost::addressof(address->second), boost::forward<A2>(a2));
}
-#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
-
- template <typename Alloc, typename A, typename B, typename A0>
- inline typename enable_if<emulation1<A, B, A0>, void>::type
- construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
- BOOST_FWD_REF(A0) a0)
- {
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->first),boost::forward<A0>(a0));
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->second));
- }
-
- template <typename Alloc, typename A, typename B,
- typename A0, typename A1, typename A2>
- inline typename enable_if<emulation3<A, B, A0>, void>::type
- construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
- BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2)
- {
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->first),boost::forward<A0>(a0));
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->second),
- boost::forward<A1>(a1),
- boost::forward<A2>(a2));
- }
-
- template <typename Alloc, typename A, typename B,
- typename A0, typename A1, typename A2, typename A3,
- typename... Args>
- inline void construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
- BOOST_FWD_REF(A0) a0, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2,
- BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(Args)... args)
- {
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->first),boost::forward<A0>(a0));
- boost::unordered::detail::call_construct(alloc,
- boost::addressof(address->second),
- boost::forward<A1>(a1),
- boost::forward<A2>(a2),
- boost::forward<A3>(a3),
- boost::forward<Args>(args)...);
- }
-
-#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
-#else // BOOST_NO_VARIADIC_TEMPLATES
+#else // BOOST_NO_CXX11_VARIADIC_TEMPLATES
////////////////////////////////////////////////////////////////////////////////
// Construct from emplace_args
-#define BOOST_UNORDERED_CONSTRUCT_IMPL(z, num_params, _) \
- template < \
- typename Alloc, typename T, \
- BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
- > \
- inline void construct_value_impl(Alloc&, T* address, \
- boost::unordered::detail::BOOST_PP_CAT(emplace_args,num_params) < \
- BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
- > const& args) \
- { \
- new((void*) address) T( \
- BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_FORWARD, \
- args.a)); \
- }
+ // Explicitly write out first three overloads for the sake of sane
+ // error messages.
template <typename Alloc, typename T, typename A0>
inline void construct_value_impl(Alloc&, T* address,
@@ -1090,82 +1011,45 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
);
}
+ // Use a macro for the rest.
+
+#define BOOST_UNORDERED_CONSTRUCT_IMPL(z, num_params, _) \
+ template < \
+ typename Alloc, typename T, \
+ BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
+ > \
+ inline void construct_value_impl(Alloc&, T* address, \
+ boost::unordered::detail::BOOST_PP_CAT(emplace_args,num_params) < \
+ BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
+ > const& args) \
+ { \
+ new((void*) address) T( \
+ BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_FORWARD, \
+ args.a)); \
+ }
+
BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
BOOST_UNORDERED_CONSTRUCT_IMPL, _)
#undef BOOST_UNORDERED_CONSTRUCT_IMPL
+ // Construct with piece_construct
+
template <typename Alloc, typename A, typename B,
typename A0, typename A1, typename A2>
inline void construct_value_impl(Alloc& alloc, std::pair<A, B>* address,
boost::unordered::detail::emplace_args3<A0, A1, A2> const& args,
- typename enable_if<piecewise3<A, B, A0>, void*>::type = 0)
+ typename enable_if<use_piecewise<A0>, void*>::type = 0)
{
- boost::unordered::detail::construct_from_tuple(alloc,
+ boost::unordered::detail::func::construct_from_tuple(alloc,
boost::addressof(address->first), args.a1);
- boost::unordered::detail::construct_from_tuple(alloc,
+ boost::unordered::detail::func::construct_from_tuple(alloc,
boost::addressof(address->second), args.a2);
}
-#if defined(BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT)
+#endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES
- template <typename Alloc, typename A, typename B, typename A0>
- inline void construct_value_impl(Alloc&, std::pair<A, B>* address,
- boost::unordered::detail::emplace_args1<A0> const& args,
- typename enable_if<emulation1<A, B, A0>, void*>::type = 0)
- {
- new((void*) boost::addressof(address->first)) A(
- boost::forward<A0>(args.a0));
- new((void*) boost::addressof(address->second)) B();
- }
-
- template <typename Alloc, typename A, typename B,
- typename A0, typename A1, typename A2>
- inline void construct_value_impl(Alloc&, std::pair<A, B>* address,
- boost::unordered::detail::emplace_args3<A0, A1, A2> const& args,
- typename enable_if<emulation3<A, B, A0>, void*>::type = 0)
- {
- new((void*) boost::addressof(address->first)) A(
- boost::forward<A0>(args.a0));
- new((void*) boost::addressof(address->second)) B(
- boost::forward<A1>(args.a1),
- boost::forward<A2>(args.a2));
- }
-
-#define BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL(z, num_params, _) \
- template <typename Alloc, typename A, typename B, \
- BOOST_PP_ENUM_PARAMS_Z(z, num_params, typename A) \
- > \
- inline void construct_value_impl(Alloc&, std::pair<A, B>* address, \
- boost::unordered::detail::BOOST_PP_CAT(emplace_args, num_params) < \
- BOOST_PP_ENUM_PARAMS_Z(z, num_params, A) \
- > const& args) \
- { \
- new((void*) boost::addressof(address->first)) A( \
- boost::forward<A0>(args.a0)); \
- new((void*) boost::addressof(address->second)) B( \
- BOOST_PP_ENUM_##z(BOOST_PP_DEC(num_params), \
- BOOST_UNORDERED_CALL_FORWARD2, args.a)); \
- }
-
-#define BOOST_UNORDERED_CALL_FORWARD2(z, i, a) \
- BOOST_UNORDERED_CALL_FORWARD(z, BOOST_PP_INC(i), a)
-
- BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL(1, 2, _)
- BOOST_PP_REPEAT_FROM_TO(4, BOOST_UNORDERED_EMPLACE_LIMIT,
- BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL, _)
-
-#undef BOOST_UNORDERED_CONSTRUCT_PAIR_IMPL
-#undef BOOST_UNORDERED_CALL_FORWARD2
-
-#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
-#endif // BOOST_NO_VARIADIC_TEMPLATES
-
-}}}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// Some helper functions for allocating & constructing
+}}}}
namespace boost { namespace unordered { namespace detail {
@@ -1197,8 +1081,10 @@ namespace boost { namespace unordered { namespace detail {
~array_constructor() {
if (ptr_) {
- for(pointer p = ptr_; p != constructed_; ++p)
- traits::destroy(alloc_, boost::addressof(*p));
+ for(pointer p = ptr_; p != constructed_; ++p) {
+ boost::unordered::detail::func::destroy(
+ boost::addressof(*p));
+ }
traits::deallocate(alloc_, ptr_, length_);
}
@@ -1211,8 +1097,9 @@ namespace boost { namespace unordered { namespace detail {
length_ = l;
ptr_ = traits::allocate(alloc_, length_);
pointer end = ptr_ + static_cast<std::ptrdiff_t>(length_);
- for(constructed_ = ptr_; constructed_ != end; ++constructed_)
- traits::construct(alloc_, boost::addressof(*constructed_), v);
+ for(constructed_ = ptr_; constructed_ != end; ++constructed_) {
+ new ((void*) boost::addressof(*constructed_)) V(v);
+ }
}
pointer get() const