Simplify intrusive dependencies dropping Boost.Core

This commit is contained in:
Ion Gaztañaga
2023-02-01 21:35:40 +01:00
parent e4ec3fb937
commit 1014e97fb2
5 changed files with 42 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
# Copyright 2019 Mike Dev # Copyright 2019 Mike Dev
# Copyright 2023 Ion Gaztanaga
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
@@ -16,7 +17,6 @@ target_link_libraries( boost_intrusive
Boost::assert Boost::assert
Boost::config Boost::config
Boost::container_hash Boost::container_hash
Boost::core
Boost::move Boost::move
Boost::static_assert Boost::static_assert
) )

View File

@@ -16,8 +16,8 @@
#include <boost/intrusive/detail/config_begin.hpp> #include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/intrusive_fwd.hpp> #include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/workaround.hpp>
#include <boost/intrusive/detail/algo_type.hpp> #include <boost/intrusive/detail/algo_type.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <cstddef> #include <cstddef>
#if defined(BOOST_HAS_PRAGMA_ONCE) #if defined(BOOST_HAS_PRAGMA_ONCE)
@@ -405,7 +405,7 @@ class circular_list_algorithms
new_f = cur; new_f = cur;
bcur = cur; bcur = cur;
cur = node_traits::get_next(cur); cur = node_traits::get_next(cur);
BOOST_TRY{ BOOST_INTRUSIVE_TRY{
//Main loop //Main loop
while(cur != end){ while(cur != end){
if(pred(cur)){ //Might throw if(pred(cur)){ //Might throw
@@ -426,12 +426,12 @@ class circular_list_algorithms
} }
} }
} }
BOOST_CATCH(...){ BOOST_INTRUSIVE_CATCH(...){
node_traits::set_next (last_to_remove, new_f); node_traits::set_next (last_to_remove, new_f);
node_traits::set_previous(new_f, last_to_remove); node_traits::set_previous(new_f, last_to_remove);
BOOST_RETHROW; BOOST_INTRUSIVE_RETHROW;
} }
BOOST_CATCH_END BOOST_INTRUSIVE_CATCH_END
node_traits::set_next(last_to_remove, new_f); node_traits::set_next(last_to_remove, new_f);
node_traits::set_previous(new_f, last_to_remove); node_traits::set_previous(new_f, last_to_remove);
break; break;

View File

@@ -22,7 +22,7 @@
#endif #endif
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/core/no_exceptions_support.hpp> #include <boost/intrusive/detail/workaround.hpp>
#include <boost/move/detail/placement_new.hpp> #include <boost/move/detail/placement_new.hpp>
#include <boost/move/detail/force_ptr.hpp> #include <boost/move/detail/force_ptr.hpp>
@@ -55,20 +55,20 @@ class array_initializer
{ {
char *init_buf = (char*)rawbuf; char *init_buf = (char*)rawbuf;
std::size_t i = 0; std::size_t i = 0;
BOOST_TRY{ BOOST_INTRUSIVE_TRY{
for(; i != N; ++i){ for(; i != N; ++i){
::new(init_buf, boost_move_new_t()) T(init); ::new(init_buf, boost_move_new_t()) T(init);
init_buf += sizeof(T); init_buf += sizeof(T);
} }
} }
BOOST_CATCH(...){ BOOST_INTRUSIVE_CATCH(...){
while(i--){ while(i--){
init_buf -= sizeof(T); init_buf -= sizeof(T);
move_detail::force_ptr<T*>(init_buf)->~T(); move_detail::force_ptr<T*>(init_buf)->~T();
} }
BOOST_RETHROW; BOOST_INTRUSIVE_RETHROW;
} }
BOOST_CATCH_END BOOST_INTRUSIVE_CATCH_END
} }
operator T* () operator T* ()

View File

@@ -22,9 +22,9 @@
#endif #endif
#include <boost/intrusive/intrusive_fwd.hpp> #include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/workaround.hpp>
#include <boost/intrusive/detail/assert.hpp> #include <boost/intrusive/detail/assert.hpp>
#include <boost/intrusive/detail/algo_type.hpp> #include <boost/intrusive/detail/algo_type.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <cstddef> #include <cstddef>
namespace boost { namespace boost {
@@ -126,7 +126,7 @@ class common_slist_algorithms
new_f = cur; new_f = cur;
bcur = cur; bcur = cur;
cur = node_traits::get_next(cur); cur = node_traits::get_next(cur);
BOOST_TRY{ BOOST_INTRUSIVE_TRY{
//Main loop //Main loop
while(cur != end){ while(cur != end){
if(pred(cur)){ //Might throw if(pred(cur)){ //Might throw
@@ -145,11 +145,11 @@ class common_slist_algorithms
} }
} }
} }
BOOST_CATCH(...){ BOOST_INTRUSIVE_CATCH(...){
node_traits::set_next(last_to_remove, new_f); node_traits::set_next(last_to_remove, new_f);
BOOST_RETHROW; BOOST_INTRUSIVE_RETHROW;
} }
BOOST_CATCH_END BOOST_INTRUSIVE_CATCH_END
node_traits::set_next(last_to_remove, new_f); node_traits::set_next(last_to_remove, new_f);
break; break;
} }

View File

@@ -55,4 +55,30 @@
#define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE #define BOOST_INTRUSIVE_FORCEINLINE BOOST_FORCEINLINE
#endif #endif
#if !(defined BOOST_NO_EXCEPTIONS)
# define BOOST_INTRUSIVE_TRY { try
# define BOOST_INTRUSIVE_CATCH(x) catch(x)
# define BOOST_INTRUSIVE_RETHROW throw;
# define BOOST_INTRUSIVE_CATCH_END }
#else
# if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
# define BOOST_INTRUSIVE_TRY { if (true)
# define BOOST_INTRUSIVE_CATCH(x) else if (false)
# else
// warning C4127: conditional expression is constant
# define BOOST_INTRUSIVE_TRY { \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (true) \
__pragma(warning(pop))
# define BOOST_INTRUSIVE_CATCH(x) else \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (false) \
__pragma(warning(pop))
# endif
# define BOOST_INTRUSIVE_RETHROW
# define BOOST_INTRUSIVE_CATCH_END }
#endif
#endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP #endif //#ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP