mirror of
https://github.com/boostorg/unordered.git
synced 2025-05-11 21:44:01 +00:00
Try supporting reference parameters in pairs. Probably not required.
[SVN r56441]
This commit is contained in:
parent
b75b7dd5ac
commit
31cd8f4e16
@ -106,7 +106,7 @@ namespace unordered_detail {
|
||||
{
|
||||
return v.first;
|
||||
}
|
||||
/*
|
||||
|
||||
template <class Second>
|
||||
static key_type const& extract(
|
||||
std::pair<key_type&, Second> const& v)
|
||||
@ -120,7 +120,6 @@ namespace unordered_detail {
|
||||
{
|
||||
return v.first;
|
||||
}
|
||||
*/
|
||||
|
||||
#if defined(BOOST_UNORDERED_STD_FORWARD)
|
||||
template <class Arg1, class... Args>
|
||||
|
@ -93,6 +93,10 @@ namespace test
|
||||
return x1.type_ != x2.type_;
|
||||
}
|
||||
};
|
||||
|
||||
std::size_t hash_value(test::object const& x) {
|
||||
return hash()(x);
|
||||
}
|
||||
|
||||
class less
|
||||
{
|
||||
|
@ -27,6 +27,7 @@ test-suite unordered
|
||||
[ run move_tests.cpp : : : <test-info>always_show_run_output ]
|
||||
[ run assign_tests.cpp ]
|
||||
[ run insert_tests.cpp ]
|
||||
[ run insert_range_tests.cpp ]
|
||||
[ run insert_stable_tests.cpp ]
|
||||
[ run unnecessary_copy_tests.cpp ]
|
||||
[ run erase_tests.cpp ]
|
||||
|
40
test/unordered/insert_range_tests.cpp
Normal file
40
test/unordered/insert_range_tests.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
// Copyright 2006-2009 Daniel James.
|
||||
// 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)
|
||||
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <vector>
|
||||
#include "../helpers/test.hpp"
|
||||
#include "../objects/test.hpp"
|
||||
|
||||
UNORDERED_AUTO_TEST(needless_copies_1) {
|
||||
std::vector<std::pair<test::object, int> > src;
|
||||
src.push_back(std::pair<test::object, int>(test::object(1, 2), 0));
|
||||
|
||||
boost::unordered_map<test::object, double> dst;
|
||||
dst[test::object(1, 2)] = 0;
|
||||
|
||||
test::object_count count = test::global_object_count;
|
||||
dst.insert(src.begin(), src.end());
|
||||
BOOST_TEST(count == test::global_object_count);
|
||||
}
|
||||
|
||||
UNORDERED_AUTO_TEST(needless_copies_2) {
|
||||
test::object x(1, 2);
|
||||
std::pair<test::object&, int> src(x, 0);
|
||||
|
||||
boost::unordered_map<test::object, double> dst;
|
||||
|
||||
test::object_count count = test::global_object_count;
|
||||
dst.emplace(src);
|
||||
BOOST_TEST(test::global_object_count.instances == count.instances + 1);
|
||||
BOOST_TEST_EQ(test::global_object_count.constructions, count.constructions + 1);
|
||||
|
||||
count = test::global_object_count;
|
||||
dst.emplace(src);
|
||||
BOOST_TEST_EQ(test::global_object_count, count);
|
||||
}
|
||||
|
||||
RUN_TESTS()
|
Loading…
x
Reference in New Issue
Block a user