2012-04-08 15:29:15 +00:00
|
|
|
|
2009-03-09 20:56:23 +00:00
|
|
|
// Copyright 2006-2009 Daniel James.
|
2006-12-03 23:08:17 +00:00
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// clang-format off
|
2009-11-26 23:15:30 +00:00
|
|
|
#include "../helpers/prefix.hpp"
|
2006-12-03 23:08:17 +00:00
|
|
|
#include <boost/unordered_set.hpp>
|
|
|
|
#include <boost/unordered_map.hpp>
|
2012-04-08 15:29:15 +00:00
|
|
|
#include "../helpers/postfix.hpp"
|
2017-02-19 13:05:17 +00:00
|
|
|
// clang-format on
|
2012-04-08 15:29:15 +00:00
|
|
|
|
2008-03-24 17:03:15 +00:00
|
|
|
#include "../helpers/test.hpp"
|
2006-12-03 23:08:17 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
namespace unnecessary_copy_tests {
|
2017-06-11 20:55:59 +01:00
|
|
|
struct count_copies
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
private:
|
|
|
|
BOOST_COPYABLE_AND_MOVABLE(count_copies)
|
|
|
|
public:
|
|
|
|
static int copies;
|
|
|
|
static int moves;
|
|
|
|
static int id_count;
|
|
|
|
|
|
|
|
count_copies() : tag_(0), id_(++id_count)
|
2008-01-10 22:30:46 +00:00
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
++copies;
|
|
|
|
trace_op("Default construct");
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
explicit count_copies(int tag) : tag_(tag), id_(++id_count)
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
++copies;
|
|
|
|
trace_op("Tag construct");
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// This bizarre constructor is an attempt to confuse emplace.
|
|
|
|
//
|
|
|
|
// unordered_map<count_copies, count_copies> x:
|
|
|
|
// x.emplace(count_copies(1), count_copies(2));
|
|
|
|
// x.emplace(count_copies(1), count_copies(2), count_copies(3));
|
|
|
|
//
|
|
|
|
// The first emplace should use the single argument constructor twice.
|
|
|
|
// The second emplace should use the single argument contructor for
|
|
|
|
// the key, and this constructor for the value.
|
|
|
|
count_copies(count_copies const&, count_copies const& x)
|
|
|
|
: tag_(x.tag_), id_(++id_count)
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
++copies;
|
|
|
|
trace_op("Pair construct");
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
2012-09-22 18:32:22 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
count_copies(count_copies const& x) : tag_(x.tag_), id_(++id_count)
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
++copies;
|
|
|
|
trace_op("Copy construct");
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
count_copies(BOOST_RV_REF(count_copies) x) : tag_(x.tag_), id_(++id_count)
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
x.tag_ = -1;
|
|
|
|
++moves;
|
|
|
|
trace_op("Move construct");
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
count_copies& operator=(
|
2017-06-11 20:55:59 +01:00
|
|
|
BOOST_COPY_ASSIGN_REF(count_copies) p) // Copy assignment
|
2017-02-19 13:05:17 +00:00
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
tag_ = p.tag_;
|
|
|
|
++copies;
|
|
|
|
trace_op("Copy assign");
|
|
|
|
return *this;
|
2008-01-10 22:30:46 +00:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
|
|
|
|
count_copies& operator=(BOOST_RV_REF(count_copies) p) // Move assignment
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
tag_ = p.tag_;
|
|
|
|
++moves;
|
|
|
|
trace_op("Move assign");
|
|
|
|
return *this;
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~count_copies() { trace_op("Destruct"); }
|
|
|
|
|
|
|
|
void trace_op(char const* str)
|
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM << str << ": " << tag_ << " (#" << id_
|
|
|
|
<< ")" << std::endl;
|
2017-02-19 13:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int tag_;
|
|
|
|
int id_;
|
2017-06-11 20:55:59 +01:00
|
|
|
};
|
2017-02-19 13:05:17 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
bool operator==(count_copies const& x, count_copies const& y)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
return x.tag_ == y.tag_;
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> T source() { return T(); }
|
2017-02-19 13:05:17 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
void reset()
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
count_copies::copies = 0;
|
|
|
|
count_copies::moves = 0;
|
|
|
|
|
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "\nReset\n" << std::endl;
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2006-12-03 23:08:17 +00:00
|
|
|
}
|
|
|
|
|
2007-05-19 20:04:14 +00:00
|
|
|
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP)
|
2008-03-24 17:03:15 +00:00
|
|
|
namespace boost
|
2008-01-10 22:30:46 +00:00
|
|
|
#else
|
2008-03-24 17:03:15 +00:00
|
|
|
namespace unnecessary_copy_tests
|
2007-05-19 20:04:14 +00:00
|
|
|
#endif
|
2008-03-24 17:03:15 +00:00
|
|
|
{
|
2017-06-11 20:55:59 +01:00
|
|
|
std::size_t hash_value(unnecessary_copy_tests::count_copies const& x)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
return static_cast<std::size_t>(x.tag_);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2006-12-03 23:08:17 +00:00
|
|
|
}
|
|
|
|
|
2013-12-15 17:11:26 +00:00
|
|
|
// Boost.Move doesn't seem to work very well on this compiler.
|
|
|
|
// For example for:
|
|
|
|
//
|
|
|
|
// T x;
|
|
|
|
//
|
|
|
|
// It will default construct T, and then move it in.
|
|
|
|
// For 'T const' it seems to copy.
|
|
|
|
|
|
|
|
#if defined(__IBMCPP__) && __IBMCPP__ <= 1210
|
|
|
|
#define EXTRA_CONSTRUCT_COST 1
|
|
|
|
#else
|
|
|
|
#define EXTRA_CONSTRUCT_COST 0
|
|
|
|
#endif
|
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
#define COPY_COUNT(n) \
|
2017-06-11 20:55:59 +01:00
|
|
|
if (::unnecessary_copy_tests::count_copies::copies != n) { \
|
|
|
|
BOOST_ERROR("Wrong number of copies."); \
|
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM \
|
|
|
|
<< "Number of copies: " \
|
|
|
|
<< ::unnecessary_copy_tests::count_copies::copies << " expecting: " << n \
|
|
|
|
<< std::endl; \
|
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
#define MOVE_COUNT(n) \
|
2017-06-11 20:55:59 +01:00
|
|
|
if (::unnecessary_copy_tests::count_copies::moves != n) { \
|
|
|
|
BOOST_ERROR("Wrong number of moves."); \
|
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM \
|
|
|
|
<< "Number of moves: " << ::unnecessary_copy_tests::count_copies::moves \
|
|
|
|
<< " expecting: " << n << std::endl; \
|
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
#define COPY_COUNT_RANGE(a, b) \
|
2017-06-11 20:55:59 +01:00
|
|
|
if (::unnecessary_copy_tests::count_copies::copies < a || \
|
|
|
|
::unnecessary_copy_tests::count_copies::copies > b) { \
|
|
|
|
BOOST_ERROR("Wrong number of copies."); \
|
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM \
|
|
|
|
<< "Number of copies: " \
|
|
|
|
<< ::unnecessary_copy_tests::count_copies::copies << " expecting: [" \
|
|
|
|
<< a << ", " << b << "]" << std::endl; \
|
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
#define MOVE_COUNT_RANGE(a, b) \
|
2017-06-11 20:55:59 +01:00
|
|
|
if (::unnecessary_copy_tests::count_copies::moves < a || \
|
|
|
|
::unnecessary_copy_tests::count_copies::moves > b) { \
|
|
|
|
BOOST_ERROR("Wrong number of moves."); \
|
|
|
|
BOOST_LIGHTWEIGHT_TEST_OSTREAM \
|
|
|
|
<< "Number of moves: " << ::unnecessary_copy_tests::count_copies::moves \
|
|
|
|
<< " expecting: [" << a << ", " << b << "]" << std::endl; \
|
|
|
|
}
|
2017-02-19 13:05:17 +00:00
|
|
|
#define COPY_COUNT_EXTRA(a, b) COPY_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST)
|
|
|
|
#define MOVE_COUNT_EXTRA(a, b) MOVE_COUNT_RANGE(a, a + b * EXTRA_CONSTRUCT_COST)
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
namespace unnecessary_copy_tests {
|
2017-06-11 20:55:59 +01:00
|
|
|
int count_copies::copies;
|
|
|
|
int count_copies::moves;
|
|
|
|
int count_copies::id_count;
|
2008-01-10 22:30:46 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_insert_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
reset();
|
|
|
|
x.insert(a);
|
|
|
|
COPY_COUNT(1);
|
2017-05-01 21:03:11 +01:00
|
|
|
MOVE_COUNT(0);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2017-05-01 21:03:11 +01:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_insert_rvalue_set_test(T*)
|
|
|
|
{
|
2017-05-01 21:03:11 +01:00
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
reset();
|
|
|
|
x.insert(boost::move(a));
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(1);
|
|
|
|
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a2;
|
|
|
|
reset();
|
|
|
|
x.insert(boost::move(a));
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT((x.size() == 2 ? 1 : 0));
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2017-05-01 21:03:11 +01:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_insert_rvalue_map_test(T*)
|
|
|
|
{
|
2017-05-01 21:03:11 +01:00
|
|
|
// Doesn't currently try to emulate std::pair move construction,
|
|
|
|
// so std::pair's require a copy. Could try emulating it in
|
|
|
|
// construct_from_args.
|
|
|
|
|
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
reset();
|
|
|
|
x.insert(boost::move(a));
|
|
|
|
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
#else
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a2;
|
|
|
|
reset();
|
|
|
|
x.insert(boost::move(a));
|
|
|
|
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
|
|
|
COPY_COUNT((x.size() == 2 ? 1 : 0));
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
#else
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT((x.size() == 2 ? 1 : 0));
|
|
|
|
#endif
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2006-12-03 23:08:17 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
boost::unordered_set<count_copies>* set;
|
|
|
|
boost::unordered_multiset<count_copies>* multiset;
|
|
|
|
boost::unordered_map<int, count_copies>* map;
|
|
|
|
boost::unordered_multimap<int, count_copies>* multimap;
|
2006-12-03 23:08:17 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(unnecessary_copy_insert_test, ((set)(multiset)(map)(multimap)))
|
|
|
|
UNORDERED_TEST(unnecessary_copy_insert_rvalue_set_test, ((set)(multiset)))
|
|
|
|
UNORDERED_TEST(unnecessary_copy_insert_rvalue_map_test, ((map)(multimap)))
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
COPY_COUNT(1);
|
|
|
|
x.emplace(a);
|
|
|
|
COPY_COUNT(2);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_rvalue_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
x.emplace(source<BOOST_DEDUCED_TYPENAME T::value_type>());
|
2012-11-26 17:47:12 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(1);
|
2009-05-10 21:25:09 +00:00
|
|
|
#else
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(2);
|
2009-05-10 21:25:09 +00:00
|
|
|
#endif
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(
|
|
|
|
unnecessary_copy_emplace_test, ((set)(multiset)(map)(multimap)))
|
|
|
|
UNORDERED_TEST(
|
2017-02-19 13:05:17 +00:00
|
|
|
unnecessary_copy_emplace_rvalue_test, ((set)(multiset)(map)(multimap)))
|
2009-05-10 21:25:09 +00:00
|
|
|
|
2013-12-15 17:11:25 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_std_move_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
x.emplace(std::move(a));
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(1);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2013-12-15 17:11:25 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(
|
2017-02-19 13:05:17 +00:00
|
|
|
unnecessary_copy_emplace_std_move_test, ((set)(multiset)(map)(multimap)))
|
2013-12-15 17:11:25 +00:00
|
|
|
#endif
|
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_boost_move_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT_EXTRA(0, 1);
|
|
|
|
x.emplace(boost::move(a));
|
2012-11-26 17:47:12 +00:00
|
|
|
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(1);
|
2012-08-25 12:52:31 +00:00
|
|
|
#else
|
2017-02-19 13:05:17 +00:00
|
|
|
// Since std::pair isn't movable, move only works for sets.
|
|
|
|
COPY_COUNT_RANGE(1, 2);
|
|
|
|
MOVE_COUNT_RANGE(0, 1);
|
2012-08-25 12:52:31 +00:00
|
|
|
#endif
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(
|
2017-02-19 13:05:17 +00:00
|
|
|
unnecessary_copy_emplace_boost_move_test, ((set)(multiset)(map)(multimap)))
|
2011-08-04 22:54:26 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_boost_move_set_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
x.emplace(boost::move(a));
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(1);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(
|
|
|
|
unnecessary_copy_emplace_boost_move_set_test, ((set)(multiset)))
|
2011-08-04 22:54:26 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
template <class T> void unnecessary_copy_emplace_boost_move_map_test(T*)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
T x;
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
BOOST_DEDUCED_TYPENAME T::value_type a;
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT_EXTRA(0, 1);
|
|
|
|
x.emplace(boost::move(a));
|
2012-11-26 17:47:12 +00:00
|
|
|
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT_EXTRA(0, 1);
|
2011-08-15 20:23:29 +00:00
|
|
|
#else
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(1);
|
2009-05-10 21:25:09 +00:00
|
|
|
#endif
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2011-08-04 22:54:26 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_TEST(
|
|
|
|
unnecessary_copy_emplace_boost_move_map_test, ((map)(multimap)))
|
2009-05-10 21:25:09 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_AUTO_TEST(unnecessary_copy_emplace_set_test)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
// When calling 'source' the object is moved on some compilers, but not
|
|
|
|
// others. So count that here to adjust later.
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
source<count_copies>();
|
|
|
|
int source_cost = ::unnecessary_copy_tests::count_copies::moves;
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
boost::unordered_set<count_copies> x;
|
|
|
|
count_copies a;
|
|
|
|
x.insert(a);
|
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(0);
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
|
|
|
// 0 arguments
|
|
|
|
//
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-05-16 18:23:23 +01:00
|
|
|
#if !BOOST_UNORDERED_SUN_WORKAROUNDS1
|
2017-02-19 13:05:17 +00:00
|
|
|
// The container will have to create a copy in order to compare with
|
|
|
|
// the existing element.
|
|
|
|
reset();
|
|
|
|
x.emplace();
|
2017-05-01 21:03:11 +01:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// source_cost doesn't make much sense here, but it seems to fit.
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(source_cost);
|
2011-08-04 22:54:26 +00:00
|
|
|
#endif
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
|
|
|
// 1 argument
|
|
|
|
//
|
|
|
|
|
|
|
|
// Emplace should be able to tell that there already is an element
|
|
|
|
// without creating a new one.
|
|
|
|
reset();
|
|
|
|
x.emplace(a);
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
// A new object is created by source, but it shouldn't be moved or
|
|
|
|
// copied.
|
|
|
|
reset();
|
|
|
|
x.emplace(source<count_copies>());
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(source_cost);
|
|
|
|
|
|
|
|
// No move should take place.
|
|
|
|
reset();
|
|
|
|
x.emplace(boost::move(a));
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// Use a new value for cases where a did get moved...
|
|
|
|
count_copies b;
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// The container will have to create a copy in order to compare with
|
|
|
|
// the existing element.
|
|
|
|
reset();
|
|
|
|
x.emplace(b.tag_);
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(0);
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
|
|
|
// 2 arguments
|
|
|
|
//
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// The container will have to create b copy in order to compare with
|
|
|
|
// the existing element.
|
|
|
|
//
|
|
|
|
// Note to self: If copy_count == 0 it's an error not an optimization.
|
|
|
|
// TODO: Devise a better test.
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
2009-05-10 21:25:09 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
x.emplace(b, b);
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(0);
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-06-11 20:55:59 +01:00
|
|
|
UNORDERED_AUTO_TEST(unnecessary_copy_emplace_map_test)
|
|
|
|
{
|
2017-02-19 13:05:17 +00:00
|
|
|
// When calling 'source' the object is moved on some compilers, but not
|
|
|
|
// others. So count that here to adjust later.
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
source<count_copies>();
|
|
|
|
int source_cost = ::unnecessary_copy_tests::count_copies::moves;
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
source<std::pair<count_copies, count_copies> >();
|
|
|
|
int source_pair_cost = ::unnecessary_copy_tests::count_copies::moves;
|
2011-08-20 23:34:14 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
2011-08-18 19:29:02 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
boost::unordered_map<count_copies, count_copies> x;
|
|
|
|
// TODO: Run tests for pairs without const etc.
|
|
|
|
std::pair<count_copies const, count_copies> a;
|
|
|
|
x.emplace(a);
|
|
|
|
COPY_COUNT_EXTRA(4, 1);
|
|
|
|
MOVE_COUNT_EXTRA(0, 1);
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
//
|
|
|
|
// 0 arguments
|
|
|
|
//
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-05-16 18:23:23 +01:00
|
|
|
#if !BOOST_UNORDERED_SUN_WORKAROUNDS1
|
2017-02-19 13:05:17 +00:00
|
|
|
// COPY_COUNT(1) would be okay here.
|
|
|
|
reset();
|
|
|
|
x.emplace();
|
|
|
|
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
|
|
|
|
// This is a little odd, Visual C++ 11 seems to move the pair, which
|
|
|
|
// results in one copy (for the const key) and one move (for the
|
|
|
|
// non-const mapped value). Since 'emplace(boost::move(a))' (see below)
|
|
|
|
// has the normal result, it must be some odd consequence of how
|
|
|
|
// Visual C++ 11 handles calling move for default arguments.
|
|
|
|
COPY_COUNT(3);
|
|
|
|
MOVE_COUNT(1);
|
|
|
|
#else
|
|
|
|
COPY_COUNT_EXTRA(2, 1);
|
|
|
|
MOVE_COUNT_EXTRA(0, 1);
|
|
|
|
#endif
|
2011-09-08 21:11:16 +00:00
|
|
|
#endif
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
x.emplace(boost::unordered::piecewise_construct, boost::make_tuple(),
|
2017-06-11 20:55:59 +01:00
|
|
|
boost::make_tuple());
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 1 argument
|
|
|
|
//
|
|
|
|
|
|
|
|
reset();
|
|
|
|
x.emplace(a);
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
// A new object is created by source, but it shouldn't be moved or
|
|
|
|
// copied.
|
|
|
|
reset();
|
|
|
|
x.emplace(source<std::pair<count_copies, count_copies> >());
|
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(source_pair_cost);
|
|
|
|
|
|
|
|
#if !(defined(__GNUC__) && __cplusplus < 199900L) && \
|
2017-06-11 20:55:59 +01:00
|
|
|
!(defined(_MSC_VER) && _MSC_VER < 1600)
|
2017-02-19 13:05:17 +00:00
|
|
|
count_copies part;
|
|
|
|
reset();
|
|
|
|
std::pair<count_copies const&, count_copies const&> a_ref(part, part);
|
|
|
|
x.emplace(a_ref);
|
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(0);
|
2011-08-29 09:40:41 +00:00
|
|
|
|
2011-08-20 23:34:14 +00:00
|
|
|
#endif
|
Merge support for emplace for compilers with rvalue references and variadic templates arguments, and better use of C++0x allocators.
Merged revisions 44058-44075,44078-44084,44086-44108,44110-44365,44367,44369-44414,44416-44419,44421-44457,44467-44469,44471-44511,44513-44535,44537-44737 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/trunk
................
r44467 | danieljames | 2008-04-16 18:35:56 +0100 (Wed, 16 Apr 2008) | 2 lines
Add C++-0x support to the test allocators.
................
r44468 | danieljames | 2008-04-16 18:36:06 +0100 (Wed, 16 Apr 2008) | 2 lines
Add a C++-0x node_constructor.
................
r44469 | danieljames | 2008-04-16 18:36:16 +0100 (Wed, 16 Apr 2008) | 2 lines
C++-0x constructor for node.
................
r44516 | danieljames | 2008-04-17 21:41:48 +0100 (Thu, 17 Apr 2008) | 16 lines
Merge in my work so far on implementing emplace for compilers with variadic
template & rvalue references.
Merged revisions 44059-44062 via svnmerge from
https://svn.boost.org/svn/boost/branches/unordered/dev
........
r44059 | danieljames | 2008-04-05 17:41:25 +0100 (Sat, 05 Apr 2008) | 1 line
First stab at implementing emplace - only for compilers with variadic template & rvalue references.
........
r44062 | danieljames | 2008-04-05 19:12:09 +0100 (Sat, 05 Apr 2008) | 1 line
Better variable template arguments, need to add proper support to BoostBook.
........
................
r44616 | danieljames | 2008-04-20 13:30:19 +0100 (Sun, 20 Apr 2008) | 1 line
Merge with trunk, fixes tabs.
................
r44618 | danieljames | 2008-04-20 13:42:38 +0100 (Sun, 20 Apr 2008) | 2 lines
Some extra compile tests.
................
r44619 | danieljames | 2008-04-20 13:42:50 +0100 (Sun, 20 Apr 2008) | 2 lines
Fix an error message.
................
r44703 | danieljames | 2008-04-21 20:19:50 +0100 (Mon, 21 Apr 2008) | 15 lines
Merge latest changes from trunk.
Merged revisions 44616-44702 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r44650 | danieljames | 2008-04-20 22:08:57 +0100 (Sun, 20 Apr 2008) | 1 line
Update an include.
........
r44697 | danieljames | 2008-04-21 16:55:40 +0100 (Mon, 21 Apr 2008) | 1 line
Factor out the code for choosing the bucket count, and which bucket that hash values map to make it easier to experiment with alternative policies.
........
................
r44733 | danieljames | 2008-04-23 07:55:43 +0100 (Wed, 23 Apr 2008) | 2 lines
Remove 'reserve_extra'.
................
r44734 | danieljames | 2008-04-23 07:55:55 +0100 (Wed, 23 Apr 2008) | 2 lines
More unnecessary copy tests - showing some weakness in the emplace implementation.
................
r44735 | danieljames | 2008-04-23 07:56:06 +0100 (Wed, 23 Apr 2008) | 2 lines
More tests.
................
r44736 | danieljames | 2008-04-23 07:56:19 +0100 (Wed, 23 Apr 2008) | 2 lines
Comment out a test which requires a C++0x std::pair.
................
r44737 | danieljames | 2008-04-23 07:56:35 +0100 (Wed, 23 Apr 2008) | 2 lines
Avoid creating unnecessary copies in unordered_set::emplace and unordered_map::emplace.
................
[SVN r44738]
2008-04-23 07:09:58 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
// No move should take place.
|
|
|
|
// (since a is already in the container)
|
|
|
|
reset();
|
|
|
|
x.emplace(boost::move(a));
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 2 arguments
|
|
|
|
//
|
|
|
|
|
|
|
|
std::pair<count_copies const, count_copies> b;
|
|
|
|
|
|
|
|
reset();
|
|
|
|
x.emplace(b.first, b.second);
|
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
reset();
|
|
|
|
x.emplace(source<count_copies>(), source<count_copies>());
|
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(source_cost * 2);
|
|
|
|
|
|
|
|
// source<count_copies> creates a single copy.
|
|
|
|
reset();
|
|
|
|
x.emplace(b.first, source<count_copies>());
|
|
|
|
COPY_COUNT(1);
|
|
|
|
MOVE_COUNT(source_cost);
|
|
|
|
|
|
|
|
reset();
|
|
|
|
x.emplace(count_copies(b.first.tag_), count_copies(b.second.tag_));
|
|
|
|
COPY_COUNT(2);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
reset();
|
|
|
|
x.emplace(boost::unordered::piecewise_construct,
|
2017-06-11 20:55:59 +01:00
|
|
|
boost::make_tuple(boost::ref(b.first)),
|
|
|
|
boost::make_tuple(boost::ref(b.second)));
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
2017-04-22 18:27:49 +01:00
|
|
|
#if BOOST_UNORDERED_TUPLE_ARGS
|
2011-08-29 09:40:41 +00:00
|
|
|
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
x.emplace(boost::unordered::piecewise_construct,
|
2017-06-11 20:55:59 +01:00
|
|
|
std::make_tuple(std::ref(b.first)), std::make_tuple(std::ref(b.second)));
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
|
|
|
|
|
|
|
std::pair<count_copies const, count_copies> move_source_trial;
|
|
|
|
reset();
|
|
|
|
std::make_tuple(std::move(move_source_trial.first));
|
|
|
|
std::make_tuple(std::move(move_source_trial.second));
|
|
|
|
int tuple_move_cost = ::unnecessary_copy_tests::count_copies::moves;
|
|
|
|
int tuple_copy_cost = ::unnecessary_copy_tests::count_copies::copies;
|
|
|
|
|
|
|
|
std::pair<count_copies const, count_copies> move_source;
|
|
|
|
reset();
|
|
|
|
x.emplace(boost::unordered::piecewise_construct,
|
2017-06-11 20:55:59 +01:00
|
|
|
std::make_tuple(std::move(move_source.first)),
|
|
|
|
std::make_tuple(std::move(move_source.second)));
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(tuple_copy_cost);
|
|
|
|
MOVE_COUNT(tuple_move_cost);
|
|
|
|
|
|
|
|
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) && \
|
2017-06-11 20:55:59 +01:00
|
|
|
!(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6) && \
|
|
|
|
!(defined(BOOST_MSVC) && BOOST_MSVC < 1700)
|
2017-02-19 13:05:17 +00:00
|
|
|
reset();
|
|
|
|
x.emplace(boost::unordered::piecewise_construct,
|
2017-06-11 20:55:59 +01:00
|
|
|
std::forward_as_tuple(b.first), std::forward_as_tuple(b.second));
|
2017-02-19 13:05:17 +00:00
|
|
|
COPY_COUNT(0);
|
|
|
|
MOVE_COUNT(0);
|
2011-08-29 09:40:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2017-06-11 20:55:59 +01:00
|
|
|
}
|
2006-12-03 23:08:17 +00:00
|
|
|
}
|
2008-03-24 17:03:15 +00:00
|
|
|
|
|
|
|
RUN_TESTS()
|