mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 03:17:15 +02:00
Unordered: Better std::forward/move configuration.
[SVN r73592]
This commit is contained in:
@ -424,7 +424,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Node Constructors
|
// Node Constructors
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
template <class T, class... Args>
|
template <class T, class... Args>
|
||||||
inline void construct_impl(T*, void* address, Args&&... args)
|
inline void construct_impl(T*, void* address, Args&&... args)
|
||||||
@ -495,7 +495,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
~node_constructor();
|
~node_constructor();
|
||||||
void construct_preamble();
|
void construct_preamble();
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
void construct(Args&&... args)
|
void construct(Args&&... args)
|
||||||
{
|
{
|
||||||
|
@ -200,7 +200,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
this->find_node(bucket_index, hash, k));
|
this->find_node(bucket_index, hash, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
node_ptr emplace(Args&&... args)
|
node_ptr emplace(Args&&... args)
|
||||||
|
@ -43,7 +43,7 @@ namespace detail {
|
|||||||
return no_key();
|
return no_key();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
static no_key extract(Args const&...)
|
static no_key extract(Args const&...)
|
||||||
{
|
{
|
||||||
@ -99,7 +99,7 @@ namespace detail {
|
|||||||
return v.first;
|
return v.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class Arg1, class... Args>
|
template <class Arg1, class... Args>
|
||||||
static key_type const& extract(key_type const& k,
|
static key_type const& extract(key_type const& k,
|
||||||
Arg1 const&, Args const&...)
|
Arg1 const&, Args const&...)
|
||||||
|
@ -186,7 +186,7 @@ namespace boost { namespace unordered { namespace detail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
template<class... Args>
|
template<class... Args>
|
||||||
emplace_return emplace(Args&&... args)
|
emplace_return emplace(Args&&... args)
|
||||||
|
@ -41,9 +41,20 @@
|
|||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES) && \
|
#if !defined(BOOST_NO_RVALUE_REFERENCES) && \
|
||||||
!defined(BOOST_NO_VARIADIC_TEMPLATES)
|
!defined(BOOST_NO_VARIADIC_TEMPLATES)
|
||||||
# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||||
// STLport doesn't have std::forward.
|
# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
|
||||||
# else
|
# elif defined(_LIBCPP_VERSION)
|
||||||
# define BOOST_UNORDERED_STD_FORWARD
|
# define BOOST_UNORDERED_STD_FORWARD_MOVE
|
||||||
|
# elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||||
|
# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20090804
|
||||||
|
# define BOOST_UNORDERED_STD_FORWARD_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)
|
||||||
|
// Visual C++. A version check would be a good idea.
|
||||||
|
# define BOOST_UNORDERED_STD_FORWARD_MOVE
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -51,7 +62,7 @@
|
|||||||
#define BOOST_UNORDERED_EMPLACE_LIMIT 10
|
#define BOOST_UNORDERED_EMPLACE_LIMIT 10
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOST_UNORDERED_STD_FORWARD)
|
#if !defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||||
|
@ -216,7 +216,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
std::pair<iterator, bool> emplace(Args&&...);
|
std::pair<iterator, bool> emplace(Args&&...);
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
@ -563,7 +563,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
iterator emplace(Args&&...);
|
iterator emplace(Args&&...);
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
@ -840,7 +840,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
std::pair<BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator, bool>
|
std::pair<BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator, bool>
|
||||||
@ -1279,7 +1279,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
template <class K, class T, class H, class P, class A>
|
template <class K, class T, class H, class P, class A>
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
|
@ -213,7 +213,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
std::pair<iterator, bool> emplace(Args&&...);
|
std::pair<iterator, bool> emplace(Args&&...);
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
@ -540,7 +540,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
iterator emplace(Args&&...);
|
iterator emplace(Args&&...);
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
@ -805,7 +805,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
std::pair<BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator, bool>
|
std::pair<BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator, bool>
|
||||||
@ -1190,7 +1190,7 @@ namespace unordered
|
|||||||
|
|
||||||
// modifiers
|
// modifiers
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
|
|
||||||
template <class T, class H, class P, class A>
|
template <class T, class H, class P, class A>
|
||||||
template <class... Args>
|
template <class... Args>
|
||||||
|
@ -347,7 +347,7 @@ namespace exception
|
|||||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template<class... Args> void construct(pointer p, Args&&... args) {
|
template<class... Args> void construct(pointer p, Args&&... args) {
|
||||||
UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) {
|
UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) {
|
||||||
UNORDERED_EPOINT("Mock allocator construct function.");
|
UNORDERED_EPOINT("Mock allocator construct function.");
|
||||||
|
@ -280,7 +280,7 @@ namespace minimal
|
|||||||
|
|
||||||
void construct(pointer p, T const& t) { new((void*)p.ptr_) T(t); }
|
void construct(pointer p, T const& t) { new((void*)p.ptr_) T(t); }
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template<class... Args> void construct(pointer p, Args&&... args) {
|
template<class... Args> void construct(pointer p, Args&&... args) {
|
||||||
new((void*)p.ptr_) T(std::forward<Args>(args)...);
|
new((void*)p.ptr_) T(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ namespace test
|
|||||||
new(p) T(t);
|
new(p) T(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template<class... Args> void construct(pointer p, Args&&... args) {
|
template<class... Args> void construct(pointer p, Args&&... args) {
|
||||||
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
detail::tracker.track_construct((void*) p, sizeof(T), tag_);
|
||||||
new(p) T(std::forward<Args>(args)...);
|
new(p) T(std::forward<Args>(args)...);
|
||||||
|
@ -143,7 +143,7 @@ namespace unnecessary_copy_tests
|
|||||||
reset();
|
reset();
|
||||||
T x;
|
T x;
|
||||||
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
|
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
|
||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
COPY_COUNT(1);
|
COPY_COUNT(1);
|
||||||
#else
|
#else
|
||||||
COPY_COUNT(2);
|
COPY_COUNT(2);
|
||||||
@ -155,7 +155,7 @@ namespace unnecessary_copy_tests
|
|||||||
UNORDERED_TEST(unnecessary_copy_emplace_rvalue_test,
|
UNORDERED_TEST(unnecessary_copy_emplace_rvalue_test,
|
||||||
((set)(multiset)(map)(multimap)))
|
((set)(multiset)(map)(multimap)))
|
||||||
|
|
||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
template <class T>
|
template <class T>
|
||||||
void unnecessary_copy_emplace_move_test(T*)
|
void unnecessary_copy_emplace_move_test(T*)
|
||||||
{
|
{
|
||||||
@ -193,7 +193,7 @@ namespace unnecessary_copy_tests
|
|||||||
BOOST_DEDUCED_TYPENAME T::value_type a;
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
||||||
COPY_COUNT(1); MOVE_COUNT(0);
|
COPY_COUNT(1); MOVE_COUNT(0);
|
||||||
x.emplace(boost::move(a));
|
x.emplace(boost::move(a));
|
||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_NO_RVALUE_REFERENCES)
|
||||||
COPY_COUNT(1); MOVE_COUNT(1);
|
COPY_COUNT(1); MOVE_COUNT(1);
|
||||||
#else
|
#else
|
||||||
COPY_COUNT(2); MOVE_COUNT(0);
|
COPY_COUNT(2); MOVE_COUNT(0);
|
||||||
@ -219,7 +219,7 @@ namespace unnecessary_copy_tests
|
|||||||
// the existing element.
|
// the existing element.
|
||||||
reset();
|
reset();
|
||||||
x.emplace();
|
x.emplace();
|
||||||
#if !defined(BOOST_UNORDERED_STD_FORWARD)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
// TODO: I think that in this case the move could be delayed until
|
// TODO: I think that in this case the move could be delayed until
|
||||||
// after checking for a collision, giving MOVE_COUNT(0).
|
// after checking for a collision, giving MOVE_COUNT(0).
|
||||||
COPY_COUNT(1); MOVE_COUNT(1);
|
COPY_COUNT(1); MOVE_COUNT(1);
|
||||||
@ -243,7 +243,7 @@ namespace unnecessary_copy_tests
|
|||||||
x.emplace(source<count_copies>());
|
x.emplace(source<count_copies>());
|
||||||
COPY_COUNT(1); MOVE_COUNT(0);
|
COPY_COUNT(1); MOVE_COUNT(0);
|
||||||
|
|
||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
// No move should take place.
|
// No move should take place.
|
||||||
reset();
|
reset();
|
||||||
x.emplace(std::move(a));
|
x.emplace(std::move(a));
|
||||||
@ -315,7 +315,7 @@ namespace unnecessary_copy_tests
|
|||||||
//x.emplace(a_ref);
|
//x.emplace(a_ref);
|
||||||
//COPY_COUNT(0); MOVE_COUNT(0);
|
//COPY_COUNT(0); MOVE_COUNT(0);
|
||||||
|
|
||||||
#if !defined(BOOST_NO_RVALUE_REFERENCES)
|
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
|
||||||
// No move should take place.
|
// No move should take place.
|
||||||
// (since a is already in the container)
|
// (since a is already in the container)
|
||||||
reset();
|
reset();
|
||||||
|
Reference in New Issue
Block a user