From 4e4659cc17e926d8f047b119401c1ccc52793c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 5 Jan 2013 16:39:30 +0000 Subject: [PATCH] Fixes #7849 [SVN r82362] --- example/Jamfile.v2 | 2 +- example/doc_erasing_and_disposing.cpp | 28 ++++++++++++++++++++ example/doc_offset_ptr.cpp | 15 +++++++++++ include/boost/intrusive/detail/utilities.hpp | 8 +++--- test/Jamfile.v2 | 9 ++----- 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index 109e072..4bafc5c 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -21,7 +21,7 @@ rule test_all for local fileb in [ glob *.cpp ] { - all_rules += [ run $(fileb) /boost/thread//boost_thread + all_rules += [ run $(fileb) : # additional args : # test-files : # requirements diff --git a/example/doc_erasing_and_disposing.cpp b/example/doc_erasing_and_disposing.cpp index 4952521..8f0cf0f 100644 --- a/example/doc_erasing_and_disposing.cpp +++ b/example/doc_erasing_and_disposing.cpp @@ -9,6 +9,7 @@ // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// +#include //[doc_erasing_and_disposing #include @@ -50,18 +51,45 @@ int main() //Fill all the nodes and insert them in the list my_class_list list; + //<- + #if 1 + BOOST_TRY{ + #else + //-> try{ + //<- + #endif + //-> //Insert new objects in the container for(int i = 0; i < MaxElem; ++i) list.push_back(*new my_class(i)); //Now use remove_and_dispose_if to erase and delete the objects list.remove_and_dispose_if(is_even(), delete_disposer()); } + //<- + #if 1 + BOOST_CATCH(...){ + #else + //-> catch(...){ + //<- + #endif + //-> //If something throws, make sure that all the memory is freed list.clear_and_dispose(delete_disposer()); + //<- + #if 1 + BOOST_RETHROW + #else + //-> throw; + //<- + #endif + //-> } + //<- + BOOST_CATCH_END + //-> //Dispose remaining elements list.erase_and_dispose(list.begin(), list.end(), delete_disposer()); diff --git a/example/doc_offset_ptr.cpp b/example/doc_offset_ptr.cpp index ca54844..fb7854a 100644 --- a/example/doc_offset_ptr.cpp +++ b/example/doc_offset_ptr.cpp @@ -10,6 +10,18 @@ // ///////////////////////////////////////////////////////////////////////////// +#include + +#ifdef BOOST_NO_EXCEPTIONS + +//Interprocess does not support BOOST_NO_EXCEPTIONS so nothing to test here +int main() +{ + return 0; +} + +#else //!BOOST_NO_EXCEPTIONS + //This is needed to allow concurrent test execution in //several platforms. The shared memory must be unique //for each process... @@ -100,3 +112,6 @@ int main() return 0; } //] + +#endif //BOOST_NO_EXCEPTIONS + diff --git a/include/boost/intrusive/detail/utilities.hpp b/include/boost/intrusive/detail/utilities.hpp index 722a7a3..f0f650f 100644 --- a/include/boost/intrusive/detail/utilities.hpp +++ b/include/boost/intrusive/detail/utilities.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace boost { namespace intrusive { @@ -692,19 +693,20 @@ class array_initializer { char *init_buf = (char*)rawbuf; std::size_t i = 0; - try{ + BOOST_TRY{ for(; i != N; ++i){ new(init_buf)T(init); init_buf += sizeof(T); } } - catch(...){ + BOOST_CATCH(...){ while(i--){ init_buf -= sizeof(T); ((T*)init_buf)->~T(); } - throw; + BOOST_RETHROW; } + BOOST_CATCH_END } operator T* () diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d4f2d9d..d69d96c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,19 +20,14 @@ rule test_all for local fileb in [ glob *.cpp ] { - all_rules += [ run $(fileb) /boost/thread//boost_thread + all_rules += [ run $(fileb) : # additional args : # test-files : # requirements - acc:-lrt - acc-pa_risc:-lrt - gcc-mingw:"-lole32 -loleaut32" - hpux,gcc:"-Wl,+as,mpas" - windows,clang:"-lole32 -loleaut32 -lpsapi -ladvapi32" ] ; } return $(all_rules) ; } -test-suite intrusive_test : [ test_all r ] : multi ; \ No newline at end of file +test-suite intrusive_test : [ test_all r ] : ; \ No newline at end of file