mirror of
https://github.com/boostorg/exception.git
synced 2025-06-25 03:51:38 +02:00
Compare commits
18 Commits
boost-1.77
...
esp-idf-co
Author | SHA1 | Date | |
---|---|---|---|
d664eb9b51 | |||
e2faee265d | |||
7df9fc8a85 | |||
9259706f08 | |||
eafe6dbd5c | |||
941754ed23 | |||
0d205cd71f | |||
b8e9e98b33 | |||
54f2228f78 | |||
4d18ec3e0d | |||
929ae48aa0 | |||
1dd151ae69 | |||
076211f4b4 | |||
52da83a1d7 | |||
1ed2045e07 | |||
38769cfd6b | |||
fdfd8f49fb | |||
c5367711b7 |
66
.github/workflows/ci.yml
vendored
66
.github/workflows/ci.yml
vendored
@ -17,24 +17,17 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
@ -42,51 +35,37 @@ jobs:
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.8
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
os: ubuntu-18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
@ -94,16 +73,29 @@ jobs:
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
@ -2,6 +2,8 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
if(NOT DEFINED IDF_TARGET)
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
project(boost_exception VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
@ -30,3 +32,26 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
|
||||
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${headers}
|
||||
# src/clone_current_exception_non_intrusive.cpp
|
||||
INCLUDE_DIRS
|
||||
include
|
||||
REQUIRES
|
||||
boost_assert
|
||||
boost_config
|
||||
boost_core
|
||||
boost_smart_ptr
|
||||
boost_throw_exception
|
||||
boost_tuple
|
||||
boost_type_traits
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
|
@ -16,6 +16,7 @@ environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
@ -29,18 +30,22 @@ environment:
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <boost/current_function.hpp>
|
||||
#define <span class="RenoLink"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a></span>(x)\
|
||||
::boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>( ::boost::<span class="RenoLink"><a href="enable_error_info.html">enable_error_info</a></span>(x) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_function</a></span>(<span class="RenoLink"><a href="configuration_macros.html">BOOST_THROW_EXCEPTION_CURRENT_FUNCTION</a></span>) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_file</a></span>(__FILE__) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_line</a></span>((int)__LINE__) )
|
||||
#else
|
||||
|
@ -25,7 +25,7 @@
|
||||
<p>The cost is that boost::<span class="RenoLink"><a href="exception.html">exception</a></span> is added as a base of the exception emitted by boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span> (unless the passed type already derives from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>.)</p>
|
||||
<p>Calling boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span> does not cause dynamic memory allocations.</p>
|
||||
<h3>What is the cost of BOOST_THROW_EXCEPTION?</h3>
|
||||
<p>In addition to calling boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>, <span class="RenoLink"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a></span> invokes __FILE__, __LINE__ and the <span class="RenoLink"><a href="configuration_macros.html">BOOST_THROW_EXCEPTION_CURRENT_FUNCTION</a></span> macros. The space required to store the information is already included in sizeof(boost::<span class="RenoLink"><a href="exception.html">exception</a></span>).</p>
|
||||
<p>In addition to calling boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>, <span class="RenoLink"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a></span> invokes __FILE__ and __LINE__ macros. The space required to store the information is already included in sizeof(boost::<span class="RenoLink"><a href="exception.html">exception</a></span>).</p>
|
||||
<p>Calling <span class="RenoLink"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a></span> does not cause dynamic memory allocations.</p>
|
||||
<h3>Should I use boost::throw_exception or BOOST_THROW_EXCEPTION or just throw?</h3>
|
||||
<p>The benefit of calling boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span> instead of using throw directly is that it ensures that the emitted exception derives from boost::<span class="RenoLink"><a href="exception.html">exception</a></span> and that it is compatible with boost::<span class="RenoLink"><a href="current_exception.html">current_exception</a></span>.</p>
|
||||
|
@ -29,15 +29,15 @@ boost
|
||||
<span class="RenoLink"><a href="exception.html">exception</a></span>
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="exception_constructors.html">exception</a></span>();
|
||||
<span class="RenoLink"><a href="exception_constructors.html">exception</a></span>( <span class="RenoLink"><a href="exception.html">exception</a></span> const & x );</span>
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="exception_destructor.html">~exception</a></span>();</span>
|
||||
};</span>
|
||||
|
||||
<span class="RenoLink"><a href="exception_constructors.html">exception</a></span>( <span class="RenoLink"><a href="exception.html">exception</a></span> const & x );</span>
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="exception_destructor.html">~exception</a></span>();</span>
|
||||
};</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">template <class Tag,class T>
|
||||
class <span class="RenoLink"><a href="error_info.html">error_info</a></span>;</span>
|
||||
|
||||
class <span class="RenoLink"><a href="error_info.html">error_info</a></span>;</span>
|
||||
|
||||
typedef <span class="RenoLink"><a href="error_info.html">error_info</a></span><struct throw_function_,char const *> throw_function;
|
||||
typedef <span class="RenoLink"><a href="error_info.html">error_info</a></span><struct throw_file_,char const *> throw_file;
|
||||
typedef <span class="RenoLink"><a href="error_info.html">error_info</a></span><struct throw_line_,int> throw_line;</span>
|
||||
@ -60,14 +60,14 @@ boost
|
||||
<span class="RenoLink"><a href="error_info.html">error_info</a></span>
|
||||
{
|
||||
public:
|
||||
|
||||
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
|
||||
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const & v );</span>
|
||||
|
||||
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
|
||||
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const & v );</span>
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const & <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;
|
||||
<span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> & <span class="RenoLink"><a href="error_info_value.html">value</a></span>();</span>
|
||||
};</span>
|
||||
|
||||
<span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> & <span class="RenoLink"><a href="error_info_value.html">value</a></span>();</span>
|
||||
};</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">template <class E, class Tag, class T>
|
||||
E const & <span class="RenoLink"><a href="exception_operator_shl.html">operator<<</a></span>( E const & x, <span class="RenoLink"><a href="error_info.html">error_info</a></span><Tag,T> const & v );</span></span>
|
||||
}</span></pre>
|
||||
@ -104,11 +104,11 @@ boost
|
||||
|
||||
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">template <class E>
|
||||
std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( E const & e, bool verbose=true );
|
||||
|
||||
std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> const & p, bool verbose=true );</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">char const * <span class="RenoLink"><a href="diagnostic_information_what.html">diagnostic_information_what</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const & e, bool verbose=true ) throw();</span>
|
||||
|
||||
|
||||
std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> const & p, bool verbose=true );</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">char const * <span class="RenoLink"><a href="diagnostic_information_what.html">diagnostic_information_what</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const & e, bool verbose=true ) throw();</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">std::string <span class="RenoLink"><a href="current_exception_diagnostic_information.html">current_exception_diagnostic_information</a></span>();</span></span>
|
||||
}</span></pre>
|
||||
<p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_exception_current_exception_cast_hpp.html">boost/exception/current_exception_cast.hpp</a></span>></p>
|
||||
@ -130,17 +130,17 @@ boost
|
||||
public boost::<span class="RenoLink"><a href="exception.html">exception</a></span>
|
||||
{
|
||||
---unspecified---
|
||||
};</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">typedef <span class="RenoLink"><a href="error_info.html">error_info</a></span><struct tag_original_exception_type,std::type_info const *> <span class="RenoLink"><a href="original_exception_type.html">original_exception_type</a></span>;</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">typedef ---unspecified--- <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span>;</span>
|
||||
|
||||
};</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">typedef <span class="RenoLink"><a href="error_info.html">error_info</a></span><struct tag_original_exception_type,std::type_info const *> <span class="RenoLink"><a href="original_exception_type.html">original_exception_type</a></span>;</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">typedef ---unspecified--- <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span>;</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">template <class T>
|
||||
<span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> <span class="RenoLink"><a href="copy_exception.html">copy_exception</a></span>( T const & e );</span>
|
||||
|
||||
<span class="RenoIncludeSPAN"><span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> <span class="RenoLink"><a href="current_exception.html">current_exception</a></span>();</span>
|
||||
|
||||
<span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> <span class="RenoLink"><a href="copy_exception.html">copy_exception</a></span>( T const & e );</span>
|
||||
|
||||
<span class="RenoIncludeSPAN"><span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> <span class="RenoLink"><a href="current_exception.html">current_exception</a></span>();</span>
|
||||
|
||||
<span class="RenoIncludeSPAN">void <span class="RenoLink"><a href="rethrow_exception.html">rethrow_exception</a></span>( <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> const & ep );</span></span>
|
||||
}</span></pre>
|
||||
<p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_exception_enable_current_exception_hpp.html">boost/exception/enable_current_exception.hpp</a></span>></p>
|
||||
@ -158,7 +158,6 @@ boost
|
||||
#include <boost/current_function.hpp>
|
||||
#define <span class="RenoLink"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a></span>(x)\
|
||||
::boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>( ::boost::<span class="RenoLink"><a href="enable_error_info.html">enable_error_info</a></span>(x) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_function</a></span>(<span class="RenoLink"><a href="configuration_macros.html">BOOST_THROW_EXCEPTION_CURRENT_FUNCTION</a></span>) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_file</a></span>(__FILE__) <<\
|
||||
::boost::<span class="RenoLink"><a href="boost_exception_exception_hpp.html">throw_line</a></span>((int)__LINE__) )
|
||||
#else
|
||||
|
@ -40,6 +40,37 @@
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
struct
|
||||
std_exception_ptr_wrapper:
|
||||
std::exception
|
||||
{
|
||||
std::exception_ptr p;
|
||||
explicit std_exception_ptr_wrapper( std::exception_ptr const & ptr ) BOOST_NOEXCEPT:
|
||||
p(ptr)
|
||||
{
|
||||
}
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
explicit std_exception_ptr_wrapper( std::exception_ptr && ptr ) BOOST_NOEXCEPT:
|
||||
p(static_cast<std::exception_ptr &&>(ptr))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
};
|
||||
shared_ptr<exception_detail::clone_base const>
|
||||
inline
|
||||
wrap_exception_ptr( std::exception_ptr const & e )
|
||||
{
|
||||
exception_detail::clone_base const & base =
|
||||
boost::enable_current_exception(std_exception_ptr_wrapper(std::current_exception()));
|
||||
return shared_ptr<exception_detail::clone_base const>(base.clone());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
class exception_ptr;
|
||||
namespace exception_detail { void rethrow_exception_( exception_ptr const & ); }
|
||||
|
||||
@ -54,6 +85,12 @@ boost
|
||||
exception_ptr()
|
||||
{
|
||||
}
|
||||
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
exception_ptr( std::exception_ptr const & e ):
|
||||
ptr_(exception_detail::wrap_exception_ptr(e))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
explicit
|
||||
exception_ptr( impl const & ptr ):
|
||||
ptr_(ptr)
|
||||
@ -75,14 +112,24 @@ boost
|
||||
}
|
||||
};
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
template <class E>
|
||||
inline
|
||||
exception_ptr
|
||||
copy_exception_impl( E const & e )
|
||||
{
|
||||
return exception_ptr(boost::make_shared<E>(e));
|
||||
}
|
||||
}
|
||||
|
||||
template <class E>
|
||||
inline
|
||||
exception_ptr
|
||||
copy_exception( E const & e )
|
||||
{
|
||||
E cp = e;
|
||||
exception_detail::copy_boost_exception(&cp, &e);
|
||||
return exception_ptr(boost::make_shared<wrapexcept<E> >(cp));
|
||||
return exception_detail::copy_exception_impl(boost::enable_current_exception(e));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -307,24 +354,6 @@ boost
|
||||
return boost::copy_exception(unknown_exception(e));
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
struct
|
||||
std_exception_ptr_wrapper
|
||||
{
|
||||
std::exception_ptr p;
|
||||
explicit std_exception_ptr_wrapper( std::exception_ptr const & ptr ) BOOST_NOEXCEPT:
|
||||
p(ptr)
|
||||
{
|
||||
}
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
explicit std_exception_ptr_wrapper( std::exception_ptr && ptr ) BOOST_NOEXCEPT:
|
||||
p(static_cast<std::exception_ptr &&>(ptr))
|
||||
{
|
||||
}
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
inline
|
||||
exception_ptr
|
||||
current_exception_impl()
|
||||
@ -366,6 +395,9 @@ boost
|
||||
{
|
||||
return exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone()));
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
|
||||
catch(
|
||||
std::domain_error & e )
|
||||
{
|
||||
@ -438,29 +470,26 @@ boost
|
||||
{
|
||||
return exception_detail::current_exception_std_exception(e);
|
||||
}
|
||||
#ifdef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
// this case can be handled losslesly with std::current_exception() (see below)
|
||||
catch(
|
||||
std::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_std_exception(e);
|
||||
}
|
||||
#endif
|
||||
catch(
|
||||
boost::exception & e )
|
||||
{
|
||||
return exception_detail::current_exception_unknown_boost_exception(e);
|
||||
}
|
||||
|
||||
#endif // #ifdef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
#ifndef BOOST_NO_CXX11_HDR_EXCEPTION
|
||||
try
|
||||
{
|
||||
// wrap the std::exception_ptr in a clone-enabled Boost.Exception object
|
||||
exception_detail::clone_base const & base =
|
||||
boost::enable_current_exception(std_exception_ptr_wrapper(std::current_exception()));
|
||||
return exception_ptr(shared_ptr<exception_detail::clone_base const>(base.clone()));
|
||||
return exception_ptr(std::current_exception());
|
||||
}
|
||||
catch(
|
||||
...)
|
||||
|
@ -31,7 +31,7 @@ boost
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
std::string
|
||||
error_info_name( error_info<Tag,T> const & x )
|
||||
error_info_name( error_info<Tag,T> const & )
|
||||
{
|
||||
return tag_type_name<Tag>();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
"description": "The Boost Exception library supports transporting of arbitrary data in exception objects, and transporting of exceptions between threads.",
|
||||
"documentation": "doc/boost-exception.html",
|
||||
"category": [
|
||||
"Error-handling",
|
||||
"Emulation"
|
||||
],
|
||||
"maintainers": [
|
||||
|
@ -41,6 +41,7 @@ run no_exceptions_test.cpp : : : <exception-handling>off ;
|
||||
run errinfos_test.cpp : : : <exception-handling>on ;
|
||||
run exception_ptr_test.cpp/<define>BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR ../../thread/src/tss_null.cpp /boost/exception /boost//thread : : : <threading>multi <exception-handling>on : non_intrusive_exception_ptr_test ;
|
||||
run exception_ptr_test.cpp ../../thread/src/tss_null.cpp /boost//thread : : : <threading>multi <exception-handling>on ;
|
||||
run exception_ptr_test2.cpp ;
|
||||
|
||||
lib visibility_test_lib : visibility_test_lib.cpp : <visibility>hidden <exception-handling>on ;
|
||||
run visibility_test.cpp visibility_test_lib/<link>shared : : : <visibility>hidden <exception-handling>on ;
|
||||
|
114
test/exception_ptr_test2.cpp
Normal file
114
test/exception_ptr_test2.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_EXCEPTIONS is defined" )
|
||||
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_NO_CXX11_HDR_EXCEPTION)
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test because BOOST_NO_CXX11_HDR_EXCEPTION is defined" )
|
||||
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <exception>
|
||||
#include <new>
|
||||
#include <stdexcept>
|
||||
|
||||
class my_exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception3: public std::bad_alloc
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception4: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception5: public std::logic_error, public virtual boost::exception
|
||||
{
|
||||
public:
|
||||
|
||||
my_exception5(): std::logic_error( "" ) {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw my_exception();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw my_exception2();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception2 );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw my_exception3();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception3 );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::bad_alloc );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw my_exception4();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception4 );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
throw my_exception5();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception5 );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), std::logic_error );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user