Avoid <boost/core/no_exception_support.hpp> to simplify dependencies for the library

This commit is contained in:
Ion Gaztañaga
2023-01-15 01:23:28 +01:00
parent 12c1a6aaf4
commit d1bd02f05b
4 changed files with 33 additions and 9 deletions

View File

@ -121,7 +121,7 @@ class adaptive_xbuf
{
BOOST_ASSERT(m_size < m_capacity);
if(m_size < sz){
BOOST_TRY
BOOST_MOVE_TRY
{
::new((void*)&m_ptr[m_size]) T(::boost::move(t));
++m_size;
@ -130,7 +130,7 @@ class adaptive_xbuf
}
t = ::boost::move(m_ptr[m_size-1]);
}
BOOST_CATCH(...)
BOOST_MOVE_CATCH(...)
{
while(m_size)
{
@ -138,7 +138,7 @@ class adaptive_xbuf
m_ptr[m_size].~T();
}
}
BOOST_CATCH_END
BOOST_MOVE_CATCH_END
}
}

View File

@ -28,7 +28,6 @@
#include <boost/move/detail/iterator_traits.hpp>
#include <boost/move/detail/iterator_to_raw_pointer.hpp>
#include <boost/move/detail/addressof.hpp>
#include <boost/core/no_exceptions_support.hpp>
#if defined(BOOST_MOVE_USE_STANDARD_LIBRARY_MOVE)
#include <algorithm>
#endif
@ -122,20 +121,20 @@ F uninitialized_move(I f, I l, F r
typedef typename boost::movelib::iterator_traits<I>::value_type input_value_type;
F back = r;
BOOST_TRY{
BOOST_MOVE_TRY{
while (f != l) {
void * const addr = static_cast<void*>(::boost::move_detail::addressof(*r));
::new(addr) input_value_type(::boost::move(*f));
++f; ++r;
}
}
BOOST_CATCH(...){
BOOST_MOVE_CATCH(...){
for (; back != r; ++back){
boost::movelib::iterator_to_raw_pointer(back)->~input_value_type();
}
BOOST_RETHROW;
BOOST_MOVE_RETHROW;
}
BOOST_CATCH_END
BOOST_MOVE_CATCH_END
return r;
}

View File

@ -27,7 +27,6 @@
#include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp>
#include <boost/move/algo/move.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <algorithm> //copy, copy_backward
#include <memory> //uninitialized_copy

View File

@ -77,5 +77,31 @@ BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore(T1 const&)
}} //namespace boost::movelib {
#if !(defined BOOST_NO_EXCEPTIONS)
# define BOOST_MOVE_TRY { try
# define BOOST_MOVE_CATCH(x) catch(x)
# define BOOST_MOVE_RETHROW throw;
# define BOOST_MOVE_CATCH_END }
#else
# if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
# define BOOST_MOVE_TRY { if (true)
# define BOOST_MOVE_CATCH(x) else if (false)
# else
// warning C4127: conditional expression is constant
# define BOOST_MOVE_TRY { \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (true) \
__pragma(warning(pop))
# define BOOST_MOVE_CATCH(x) else \
__pragma(warning(push)) \
__pragma(warning(disable: 4127)) \
if (false) \
__pragma(warning(pop))
# endif
# define BOOST_MOVE_RETHROW
# define BOOST_MOVE_CATCH_END }
#endif
#endif //#ifndef BOOST_MOVE_DETAIL_WORKAROUND_HPP