Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/boost/container/slist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ class slist
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, slist& x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(this->previous(p), x, this->previous(i)); }
{ this->splice_after(this->previous(p), x, x.previous(i)); }

//! <b>Requires</b>: p must point to an element contained
//! by this list. i must point to an element contained in list x.
Expand Down Expand Up @@ -1505,7 +1505,7 @@ class slist
//! <b>Note</b>: Iterators of values obtained from list x now point to elements of this
//! list. Iterators of this list and all the references are not invalidated.
void splice(const_iterator p, slist& x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{ this->splice_after(this->previous(p), x, this->previous(first), this->previous(last)); }
{ this->splice_after(this->previous(p), x, x.previous(first), x.previous(last)); }

//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
Expand Down
12 changes: 2 additions & 10 deletions test/global_resource_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,17 @@ std::size_t allocation_count = 0;
#pragma warning (disable : 4290)
#endif

#if defined(BOOST_GCC) && (BOOST_GCC >= 40700) && (__cplusplus >= 201103L)
#define BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER
#define BOOST_CONTAINER_DELETE_EXCEPTION_SPECIFIER noexcept
#else
#define BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER throw(std::bad_alloc)
#define BOOST_CONTAINER_DELETE_EXCEPTION_SPECIFIER throw()
#endif

#if defined(BOOST_GCC) && (BOOST_GCC >= 50000)
#pragma GCC diagnostic ignored "-Wsized-deallocation"
#endif

void* operator new[](std::size_t count) BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER
void* operator new[](std::size_t count) BOOST_NOEXCEPT_IF(false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to support older containers that don't have noexcept and avoid warnings that tell us that new should throw std::bad_alloc. What is the problem with current code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I do not really understand why this commit is displayed here. To fix the splice it has nothing to do. I did this local fix in my repository only to fix the build. But if you look at the Travis CI build (8.2), you can see next error:

libs/container/test/global_resource_test.cpp:42:41: error: ISO C++17 does not allow dynamic exception specifications [-Wdynamic-exception-spec]

void* operator new[](std::size_t count) BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER

libs/container/test/global_resource_test.cpp:34:52: note: expanded from macro 'BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER'

#define BOOST_CONTAINER_NEW_EXCEPTION_SPECIFIER throw(std::bad_alloc)

libs/container/test/global_resource_test.cpp:42:41: note: use 'noexcept(false)' instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can you please open a new issue for this error, adding as much context as you can (compiler, version, flags, etc.) . I'll close this issue as your main commit was already merged. Many thanks for the report and the patch.

{
++allocation_count;
return std::malloc(count);
}

void operator delete[](void *p) BOOST_CONTAINER_DELETE_EXCEPTION_SPECIFIER
void operator delete[](void *p) BOOST_NOEXCEPT
{
--allocation_count;
return std::free(p);
Expand Down
33 changes: 33 additions & 0 deletions test/slist_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,33 @@ bool test_support_for_initializer_list()
return true;
}

bool test_for_splice()
{
{
slist<int> list1; list1.push_front(3); list1.push_front(2); list1.push_front(1); list1.push_front(0);
slist<int> list2;
slist<int> expected1; expected1.push_front(3); expected1.push_front(2); expected1.push_front(0);
slist<int> expected2; expected2.push_front(1);

list2.splice(list2.begin(), list1, ++list1.begin());

if (!(expected1 == list1 && expected2 == list2))
return false;
}
{
slist<int> list1; list1.push_front(3); list1.push_front(2); list1.push_front(1); list1.push_front(0);
slist<int> list2;
slist<int> expected1;
slist<int> expected2; expected2.push_front(3); expected2.push_front(2); expected2.push_front(1); expected2.push_front(0);

list2.splice(list2.begin(), list1, list1.begin(), list1.end());

if (!(expected1 == list1 && expected2 == list2))
return false;
}
return true;
}

struct boost_container_slist;

namespace boost {
Expand Down Expand Up @@ -207,6 +234,12 @@ int main ()
if(!test_support_for_initializer_list())
return 1;

////////////////////////////////////
// Splice testing
////////////////////////////////////
if(!test_for_splice())
return 1;

////////////////////////////////////
// Iterator testing
////////////////////////////////////
Expand Down