forked from boostorg/intrusive
Fixes #63 ("nop splice removes element")
This commit is contained in:
@@ -3894,6 +3894,7 @@ to be inserted in intrusive containers are allocated using `std::vector` or `std
|
|||||||
* [@https://github.com/boostorg/intrusive/pull/57 GitHub #57: ['UB: comparing unrelated pointers]]
|
* [@https://github.com/boostorg/intrusive/pull/57 GitHub #57: ['UB: comparing unrelated pointers]]
|
||||||
* [@https://github.com/boostorg/intrusive/issues/59 GitHub #59: ['Add noexcept support to the library]]
|
* [@https://github.com/boostorg/intrusive/issues/59 GitHub #59: ['Add noexcept support to the library]]
|
||||||
* [@https://github.com/boostorg/intrusive/issues/60 GitHub #60: ['Licensing question for math.hpp]]
|
* [@https://github.com/boostorg/intrusive/issues/60 GitHub #60: ['Licensing question for math.hpp]]
|
||||||
|
* [@https://github.com/boostorg/intrusive/issues/63 GitHub #63: ['nop splice removes element]]
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@@ -253,7 +253,7 @@ class circular_list_algorithms
|
|||||||
//! <b>Throws</b>: Nothing.
|
//! <b>Throws</b>: Nothing.
|
||||||
static void transfer(node_ptr p, node_ptr b, node_ptr e) BOOST_NOEXCEPT
|
static void transfer(node_ptr p, node_ptr b, node_ptr e) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
if (b != e) {
|
if (b != e && p != b && p != e) {
|
||||||
node_ptr prev_p(NodeTraits::get_previous(p));
|
node_ptr prev_p(NodeTraits::get_previous(p));
|
||||||
node_ptr prev_b(NodeTraits::get_previous(b));
|
node_ptr prev_b(NodeTraits::get_previous(b));
|
||||||
node_ptr prev_e(NodeTraits::get_previous(e));
|
node_ptr prev_e(NodeTraits::get_previous(e));
|
||||||
|
@@ -273,7 +273,7 @@ template < class ListType, typename ValueContainer >
|
|||||||
void test_list< ListType, ValueContainer >
|
void test_list< ListType, ValueContainer >
|
||||||
::test_swap(ValueContainer& values)
|
::test_swap(ValueContainer& values)
|
||||||
{
|
{
|
||||||
{
|
{ //splice between two lists
|
||||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||||
list_type testlist2;
|
list_type testlist2;
|
||||||
testlist2.insert (testlist2.end(), values.begin() + 2, values.begin() + 5);
|
testlist2.insert (testlist2.end(), values.begin() + 2, values.begin() + 5);
|
||||||
@@ -308,6 +308,41 @@ void test_list< ListType, ValueContainer >
|
|||||||
BOOST_TEST (testlist1.size() == 1);
|
BOOST_TEST (testlist1.size() == 1);
|
||||||
BOOST_TEST (&testlist1.front() == &values[3]);
|
BOOST_TEST (&testlist1.front() == &values[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ //splice in the same list
|
||||||
|
list_type testlist1 (values.begin(), values.begin() + 5);
|
||||||
|
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 1
|
||||||
|
testlist1.splice (testlist1.begin(), testlist1, testlist1.begin(), ++testlist1.begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 2
|
||||||
|
testlist1.splice (++testlist1.begin(), testlist1, testlist1.begin(), ++testlist1.begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 3
|
||||||
|
testlist1.splice (testlist1.begin(), testlist1, ++testlist1.begin(), ++testlist1.begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice (testlist1.begin(), testlist1, ++testlist1.begin(), ++++testlist1.begin());
|
||||||
|
{ int init_values [] = { 2, 1, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice (testlist1.begin(), testlist1, ++testlist1.begin(), ++++++testlist1.begin());
|
||||||
|
{ int init_values [] = { 1, 3, 2, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice (++++++++testlist1.begin(), testlist1, testlist1.begin(), ++++testlist1.begin());
|
||||||
|
{ int init_values [] = { 2, 4, 1, 3, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||||
list_type testlist2 (values.begin() + 3, values.begin() + 5);
|
list_type testlist2 (values.begin() + 3, values.begin() + 5);
|
||||||
|
@@ -354,6 +354,41 @@ void test_slist< ListType, ValueContainer >
|
|||||||
{ int init_values [] = { 2 };
|
{ int init_values [] = { 2 };
|
||||||
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist2.begin() ); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{ //splice in the same list
|
||||||
|
list_type testlist1 (values.begin(), values.begin() + 5);
|
||||||
|
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 1
|
||||||
|
testlist1.splice_after (testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 2
|
||||||
|
testlist1.splice_after (++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
//nop 3
|
||||||
|
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 1, 2, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 2, 1, 3, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice_after (testlist1.before_begin(), testlist1, ++testlist1.before_begin(), ++++++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 1, 3, 2, 4, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
|
||||||
|
testlist1.splice_after (++++++++testlist1.before_begin(), testlist1, testlist1.before_begin(), ++++testlist1.before_begin());
|
||||||
|
{ int init_values [] = { 2, 4, 1, 3, 5 };
|
||||||
|
TEST_INTRUSIVE_SEQUENCE( init_values, testlist1.begin() ); }
|
||||||
|
}
|
||||||
|
|
||||||
{ //Now test swap when testlist2 is empty
|
{ //Now test swap when testlist2 is empty
|
||||||
list_type testlist1 (values.begin(), values.begin() + 2);
|
list_type testlist1 (values.begin(), values.begin() + 2);
|
||||||
list_type testlist2;
|
list_type testlist2;
|
||||||
|
Reference in New Issue
Block a user