forked from boostorg/unordered
Unordered: Use Boost.Move in a few more places.
Should be better for compilers with variadic parameters, but no rvalue references. If such a thing ever exists. [SVN r78536]
This commit is contained in:
@ -45,11 +45,6 @@
|
||||
|
||||
#define BOOST_UNORDERED_EMPLACE_LIMIT 10
|
||||
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
#define BOOST_UNORDERED_VARIADIC_MOVE
|
||||
#endif
|
||||
|
||||
namespace boost { namespace unordered { namespace detail {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@ -90,10 +85,10 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// Either forwarding variadic arguments, or storing the arguments in
|
||||
// emplace_args##n
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
|
||||
#define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args
|
||||
#define BOOST_UNORDERED_EMPLACE_ARGS Args&&... args
|
||||
#define BOOST_UNORDERED_EMPLACE_ARGS BOOST_FWD_REF(Args)... args
|
||||
#define BOOST_UNORDERED_EMPLACE_FORWARD boost::forward<Args>(args)...
|
||||
|
||||
#else
|
||||
@ -330,13 +325,13 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Construct from variadic parameters
|
||||
|
||||
template <typename T, typename... Args>
|
||||
inline void construct_impl(T* address, Args&&... args)
|
||||
inline void construct_impl(T* address, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
new((void*) address) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
@ -387,7 +382,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
}
|
||||
|
||||
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
|
||||
#else // BOOST_UNORDERED_VARIADIC_MOVE
|
||||
#else // BOOST_NO_VARIADIC_TEMPLATES
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Construct from emplace_args
|
||||
@ -499,7 +494,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
#undef BOOST_UNORDERED_CALL_FORWARD2
|
||||
|
||||
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
|
||||
#endif // BOOST_UNORDERED_VARIADIC_MOVE
|
||||
#endif // BOOST_NO_VARIADIC_TEMPLATES
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Construct without using the emplace args mechanism.
|
||||
@ -525,7 +520,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, boost::)
|
||||
#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS)
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__) && \
|
||||
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
|
||||
# define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1
|
||||
# define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0
|
||||
# elif defined(BOOST_MSVC)
|
||||
# if BOOST_MSVC < 1400
|
||||
// Use container's allocator_traits for older versions of Visual
|
||||
@ -689,7 +684,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
# include <boost/type_traits/is_same.hpp>
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_UNORDERED_VARIADIC_MOVE) && \
|
||||
# if !defined(BOOST_NO_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_SFINAE_EXPR)
|
||||
# define BOOST_UNORDERED_DETAIL_FULL_CONSTRUCT 1
|
||||
# else
|
||||
@ -779,7 +774,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
max_size, U const, (), 0
|
||||
);
|
||||
|
||||
# if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
# if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
|
||||
template <typename T, typename ValueType, typename... Args>
|
||||
BOOST_UNORDERED_HAS_FUNCTION(
|
||||
@ -906,7 +901,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
static typename boost::enable_if_c<
|
||||
boost::unordered::detail::has_construct<Alloc, T, Args...>
|
||||
::value>::type
|
||||
construct(Alloc& a, T* p, Args&&... x)
|
||||
construct(Alloc& a, T* p, BOOST_FWD_REF(Args)... x)
|
||||
{
|
||||
a.construct(p, boost::forward<Args>(x)...);
|
||||
}
|
||||
@ -915,7 +910,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
static typename boost::disable_if_c<
|
||||
boost::unordered::detail::has_construct<Alloc, T, Args...>
|
||||
::value>::type
|
||||
construct(Alloc&, T* p, Args&&... x)
|
||||
construct(Alloc&, T* p, BOOST_FWD_REF(Args)... x)
|
||||
{
|
||||
new ((void*) p) T(boost::forward<Args>(x)...);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
void construct_value2(BOOST_FWD_REF(A0) a0)
|
||||
{
|
||||
BOOST_ASSERT(node_ && !constructed_);
|
||||
# if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
# if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
boost::unordered::detail::construct_node(alloc_,
|
||||
boost::addressof(*node_), boost::forward<A0>(a0));
|
||||
# else
|
||||
|
@ -497,12 +497,21 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
iterator emplace(boost::unordered::detail::emplace_args1<
|
||||
boost::unordered::detail::please_ignore_this_overload> const&)
|
||||
{
|
||||
BOOST_ASSERT(false);
|
||||
return iterator();
|
||||
}
|
||||
# else
|
||||
iterator emplace(
|
||||
boost::unordered::detail::please_ignore_this_overload const&)
|
||||
{
|
||||
BOOST_ASSERT(false);
|
||||
return iterator();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||
|
@ -56,7 +56,7 @@ namespace detail {
|
||||
return no_key();
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
static no_key extract(Args const&...)
|
||||
{
|
||||
@ -111,7 +111,7 @@ namespace detail {
|
||||
return v.first;
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class Arg1, class... Args>
|
||||
static key_type const& extract(key_type const& k,
|
||||
Arg1 const&, Args const&...)
|
||||
@ -150,12 +150,12 @@ namespace detail {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
|
||||
#define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_) \
|
||||
template <typename T2> \
|
||||
static no_key extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<> const&, T2&&) \
|
||||
namespace_::tuple<> const&, BOOST_FWD_REF(T2)) \
|
||||
{ \
|
||||
return no_key(); \
|
||||
} \
|
||||
@ -163,7 +163,7 @@ namespace detail {
|
||||
template <typename T, typename T2> \
|
||||
static typename is_key<key_type, T>::type \
|
||||
extract(boost::unordered::piecewise_construct_t, \
|
||||
namespace_::tuple<T> const& k, T2&&) \
|
||||
namespace_::tuple<T> const& k, BOOST_FWD_REF(T2)) \
|
||||
{ \
|
||||
return typename is_key<key_type, T>::type( \
|
||||
namespace_::get<0>(k)); \
|
||||
|
@ -379,7 +379,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
// exception (need strong safety in such a case).
|
||||
node_constructor a(this->node_alloc());
|
||||
a.construct_node();
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
a.construct_value(boost::unordered::piecewise_construct,
|
||||
boost::make_tuple(k), boost::make_tuple());
|
||||
#else
|
||||
@ -395,22 +395,30 @@ namespace boost { namespace unordered { namespace detail {
|
||||
}
|
||||
|
||||
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
# if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
emplace_return emplace(boost::unordered::detail::emplace_args1<
|
||||
boost::unordered::detail::please_ignore_this_overload> const&)
|
||||
{
|
||||
BOOST_ASSERT(false);
|
||||
return emplace_return(this->begin(), false);
|
||||
}
|
||||
# else
|
||||
emplace_return emplace(
|
||||
boost::unordered::detail::please_ignore_this_overload const&)
|
||||
{
|
||||
BOOST_ASSERT(false);
|
||||
return emplace_return(this->begin(), false);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
|
||||
emplace_return emplace(BOOST_UNORDERED_EMPLACE_ARGS)
|
||||
{
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
return emplace_impl(
|
||||
extractor::extract(BOOST_UNORDERED_EMPLACE_FORWARD),
|
||||
BOOST_UNORDERED_EMPLACE_FORWARD);
|
||||
|
||||
#else
|
||||
return emplace_impl(
|
||||
extractor::extract(args.a0, args.a1),
|
||||
@ -418,7 +426,7 @@ namespace boost { namespace unordered { namespace detail {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <typename A0>
|
||||
emplace_return emplace(
|
||||
boost::unordered::detail::emplace_args1<A0> const& args)
|
||||
|
@ -232,15 +232,15 @@ namespace unordered
|
||||
|
||||
// emplace
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
std::pair<iterator, bool> emplace(Args&&... args)
|
||||
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator, Args&&... args)
|
||||
iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...).first;
|
||||
}
|
||||
@ -719,15 +719,15 @@ namespace unordered
|
||||
|
||||
// emplace
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
iterator emplace(Args&&... args)
|
||||
iterator emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator, Args&&... args)
|
||||
iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -230,15 +230,15 @@ namespace unordered
|
||||
|
||||
// emplace
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
std::pair<iterator, bool> emplace(Args&&... args)
|
||||
std::pair<iterator, bool> emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator, Args&&... args)
|
||||
iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...).first;
|
||||
}
|
||||
@ -703,15 +703,15 @@ namespace unordered
|
||||
|
||||
// emplace
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template <class... Args>
|
||||
iterator emplace(Args&&... args)
|
||||
iterator emplace(BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
iterator emplace_hint(const_iterator, Args&&... args)
|
||||
iterator emplace_hint(const_iterator, BOOST_FWD_REF(Args)... args)
|
||||
{
|
||||
return table_.emplace(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -168,8 +168,8 @@ namespace test
|
||||
new(p) T(t);
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
template<typename... Args> void construct(T* p, Args&&... args) {
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<typename... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
new(p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -357,9 +357,9 @@ namespace exception
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
template<class... Args> void construct(T* p, Args&&... args) {
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) {
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
UNORDERED_SCOPE(allocator::construct(pointer, BOOST_FWD_REF(Args)...)) {
|
||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||
new(p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -367,8 +367,8 @@ namespace minimal
|
||||
|
||||
void construct(T* p, T const& t) { new((void*)p) T(t); }
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
template<class... Args> void construct(T* p, Args&&... args) {
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
new((void*)p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
@ -439,8 +439,8 @@ namespace minimal
|
||||
|
||||
void construct(T* p, T const& t) { new((void*)p) T(t); }
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
template<class... Args> void construct(T* p, Args&&... args) {
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
new((void*)p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
#endif
|
||||
|
@ -259,8 +259,8 @@ namespace test
|
||||
new(p) T(t);
|
||||
}
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
template<class... Args> void construct(T* p, Args&&... args) {
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
template<class... Args> void construct(T* p, BOOST_FWD_REF(Args)... args) {
|
||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||
new(p) T(boost::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -11,23 +11,6 @@
|
||||
#include <iostream>
|
||||
#include "../helpers/test.hpp"
|
||||
|
||||
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
|
||||
# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
|
||||
# elif defined(_LIBCPP_VERSION)
|
||||
# define BOOST_UNORDERED_VARIADIC_MOVE
|
||||
# elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||
# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20090804
|
||||
# define BOOST_UNORDERED_VARIADIC_MOVE
|
||||
# endif
|
||||
# elif defined(__STL_CONFIG_H)
|
||||
# elif defined(__MSL_CPP__)
|
||||
# elif defined(__IBMCPP__)
|
||||
# elif defined(MSIPL_COMPILE_H)
|
||||
# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace unnecessary_copy_tests
|
||||
{
|
||||
struct count_copies
|
||||
@ -262,7 +245,7 @@ namespace unnecessary_copy_tests
|
||||
// the existing element.
|
||||
reset();
|
||||
x.emplace();
|
||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
||||
#if !defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||
// source_cost doesn't make much sense here, but it seems to fit.
|
||||
COPY_COUNT(1); MOVE_COUNT(source_cost);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user