Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74086 - in trunk: boost/unordered/detail libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2011-08-27 07:29:04


Author: danieljames
Date: 2011-08-27 07:29:04 EDT (Sat, 27 Aug 2011)
New Revision: 74086
URL: http://svn.boost.org/trac/boost/changeset/74086

Log:
Unordered: Fix more calls to std::forward.
Text files modified:
   trunk/boost/unordered/detail/buckets.hpp | 6 +++-
   trunk/libs/unordered/test/unordered/insert_tests.cpp | 47 ++++++++++++++++++++++++++++++++++++---
   2 files changed, 47 insertions(+), 6 deletions(-)

Modified: trunk/boost/unordered/detail/buckets.hpp
==============================================================================
--- trunk/boost/unordered/detail/buckets.hpp (original)
+++ trunk/boost/unordered/detail/buckets.hpp 2011-08-27 07:29:04 EDT (Sat, 27 Aug 2011)
@@ -574,7 +574,8 @@
     inline typename boost::disable_if<emulated_pair_constructor<T>, void>::type
     construct_impl(void* address, Arg1&& arg1, Arg2&& arg2, Args&&... args)
     {
- new(address) T(std::forward<Arg1, Arg2, Args>(arg1, arg2, args)...);
+ new(address) T(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2),
+ std::forward<Args>(args)...);
     }
 
     template <class T, class Arg1, class Arg2, class... Args>
@@ -582,7 +583,8 @@
     construct_impl(void* address, Arg1&& arg1, Arg2&& arg2, Args&&... args)
     {
         new(address) T(std::forward<Arg1>(arg1),
- typename T::second_type(std::forward<Arg2, Args>(arg2, args)...));
+ typename T::second_type(
+ std::forward<Arg2>(arg2), std::forward<Args>(args)...));
     }
 
 #else

Modified: trunk/libs/unordered/test/unordered/insert_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/insert_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/insert_tests.cpp 2011-08-27 07:29:04 EDT (Sat, 27 Aug 2011)
@@ -516,14 +516,24 @@
 
 struct overloaded_constructor
 {
- overloaded_constructor(int x = 1, int y = 2, int z = 3)
- : x(x), y(y), z(z) {}
+ overloaded_constructor(int x1 = 1, int x2 = 2, int x3 = 3, int x4 = 4)
+ : x1(x1), x2(x2), x3(x3), x4(x4) {}
 
- int x, y, z;
+ int x1, x2, x3, x4;
     
     bool operator==(overloaded_constructor const& rhs) const
     {
- return x == rhs.x && y == rhs.y && z == rhs.z;
+ return x1 == rhs.x1 && x2 == rhs.x2 && x3 == rhs.x3 && x4 == rhs.x4;
+ }
+
+ friend std::size_t hash_value(overloaded_constructor const& x)
+ {
+ std::size_t hash = 0;
+ boost::hash_combine(hash, x.x1);
+ boost::hash_combine(hash, x.x2);
+ boost::hash_combine(hash, x.x3);
+ boost::hash_combine(hash, x.x4);
+ return hash;
     }
 };
 
@@ -554,6 +564,35 @@
         x.find(7)->second == overloaded_constructor(8, 9, 10));
 }
 
+UNORDERED_AUTO_TEST(set_emplace_test)
+{
+ boost::unordered_set<overloaded_constructor> x;
+ overloaded_constructor check;
+
+ x.emplace();
+ BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
+
+ x.clear();
+ x.emplace(1);
+ check = overloaded_constructor(1);
+ BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
+
+ x.clear();
+ x.emplace(2, 3);
+ check = overloaded_constructor(2, 3);
+ BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
+
+ x.clear();
+ x.emplace(4, 5, 6);
+ check = overloaded_constructor(4, 5, 6);
+ BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
+
+ x.clear();
+ x.emplace(7, 8, 9, 10);
+ check = overloaded_constructor(7, 8, 9, 10);
+ BOOST_TEST(x.find(check) != x.end() && *x.find(check) == check);
+}
+
 }
 
 RUN_TESTS()


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk