Fixes Boost Trac #11992: "Add an overload of insert_check taking a key_type"

This commit is contained in:
Ion Gaztañaga committed 2016-03-01 21:22:28 +01:00
1 parent 2548ae30e1
commit 4cf38987a8
18 files changed
+277 -58

No files matched your search

+9 -13
View File
@@ -191,14 +191,6 @@ struct prio_comp
{ return this->priority_compare<int>::operator()(k.int_value(), v.int_value()); }
};
template<class ValueType>
struct prio_comp<ValueType, ValueType>
: priority_compare<ValueType>
{
bool operator()(const ValueType &v1, const ValueType &v2) const
{ return this->priority_compare<ValueType>::operator()(v1, v2); }
};
template<class ValueTraits, class ContainerDefiner>
void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
(value_cont_type& values, detail::true_type)
@@ -208,14 +200,16 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
typedef typename set_type::key_of_value key_of_value;
typedef typename set_type::key_type key_type;
typedef typename set_type::value_type value_type;
typedef prio_comp<value_type, key_type> prio_comp_t;
typedef priority_compare<key_type> prio_comp_t;
{
set_type testset;
testset.insert(values.begin(), values.begin() + values.size());
value_type v(1);
typename set_type::insert_commit_data data;
BOOST_TEST (!testset.insert_check(key_of_value()(v), testset.key_comp(), prio_comp_t(), data).second);
BOOST_TEST (!testset.insert_check(testset.begin(), key_of_value()(v), testset.key_comp(), prio_comp_t(), data).second);
BOOST_TEST ((!testset.insert_check(key_of_value()(v), testset.key_comp(), prio_comp_t(), data).second));
BOOST_TEST ((!testset.insert_check(testset.begin(), key_of_value()(v), testset.key_comp(), prio_comp_t(), data).second));
BOOST_TEST ((!testset.insert_check(key_of_value()(v), data).second));
BOOST_TEST ((!testset.insert_check(testset.begin(), key_of_value()(v), data).second));
}
}
@@ -232,8 +226,10 @@ void test_generic_set<ValueTraits, ContainerDefiner>::test_insert_advanced
testset.insert(values.begin(), values.begin() + values.size());
value_type v(1);
typename set_type::insert_commit_data data;
BOOST_TEST (!testset.insert_check(key_of_value()(v), testset.key_comp(), data).second);
BOOST_TEST (!testset.insert_check(testset.begin(), key_of_value()(v), testset.key_comp(), data).second);
BOOST_TEST ((!testset.insert_check(key_of_value()(v), testset.key_comp(), data).second));
BOOST_TEST ((!testset.insert_check(testset.begin(), key_of_value()(v), testset.key_comp(), data).second));
BOOST_TEST ((!testset.insert_check(key_of_value()(v), data).second));
BOOST_TEST ((!testset.insert_check(testset.begin(), key_of_value()(v), data).second));
}
}
+8 -3
View File
@@ -78,14 +78,14 @@ void test_unordered<ValueTraits, ContainerDefiner>::
test::test_maybe_unique_container(testset, values, select_t());
}
{
value_cont_type values(BucketSize);
value_cont_type vals(BucketSize);
for (int i = 0; i < (int)BucketSize; ++i)
(&values[i])->value_ = i;
(&vals[i])->value_ = i;
typename unordered_type::bucket_type buckets [BucketSize];
unordered_type testset(bucket_traits(
pointer_traits<typename unordered_type::bucket_ptr>::
pointer_to(buckets[0]), BucketSize));
testset.insert(values.begin(), values.end());
testset.insert(vals.begin(), vals.end());
test::test_iterator_forward(testset);
}
test_sort(values);
@@ -162,6 +162,7 @@ void test_unordered<ValueTraits, ContainerDefiner>
typedef typename ContainerDefiner::template container
<>::type unordered_set_type;
typedef typename unordered_set_type::bucket_traits bucket_traits;
typedef typename unordered_set_type::key_of_value key_of_value;
typename unordered_set_type::bucket_type buckets [BucketSize];
unordered_set_type testset(bucket_traits(
@@ -169,6 +170,10 @@ void test_unordered<ValueTraits, ContainerDefiner>
pointer_to(buckets[0]), BucketSize));
testset.insert(&values[0] + 2, &values[0] + 5);
typename unordered_set_type::insert_commit_data commit_data;
BOOST_TEST ((!testset.insert_check(key_of_value()(values[2]), commit_data).second));
BOOST_TEST (( testset.insert_check(key_of_value()(values[0]), commit_data).second));
const unordered_set_type& const_testset = testset;
if(unordered_set_type::incremental)
{