mirror of
https://github.com/boostorg/throw_exception.git
synced 2025-07-15 21:42:05 +02:00
Compare commits
7 Commits
feature/th
...
boost-1.81
Author | SHA1 | Date | |
---|---|---|---|
d307a2d4a7 | |||
b0add8fa4e | |||
a4cb03745c | |||
ce1065a845 | |||
d86a6220d5 | |||
f2b7655016 | |||
68d092f4d7 |
178
.github/workflows/ci.yml
vendored
178
.github/workflows/ci.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
@ -45,8 +45,11 @@ jobs:
|
||||
install: g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11
|
||||
os: ubuntu-22.04
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
@ -97,9 +100,19 @@ jobs:
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@ -151,10 +164,6 @@ jobs:
|
||||
cxxstd: "14,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2016
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
@ -204,3 +213,156 @@ jobs:
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
@ -44,3 +44,7 @@ enable `boost::exception_ptr` support.
|
||||
The source location of the exception thrown by `boost::throw_with_location`
|
||||
can be retrieved, after `catch(std::exception const & x)`, by using
|
||||
`boost::get_throw_location(x)`.
|
||||
|
||||
`boost::get_throw_location` also works for exceptions thrown by the two argument
|
||||
overload of `boost::throw_exception`, or by `BOOST_THROW_EXCEPTION`; in this case
|
||||
it returns the source location stored in the `boost::exception` base class.
|
||||
|
@ -59,7 +59,7 @@ logical throw point, instead of always pointing into the helper.
|
||||
----
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <boost/core/verbose_terminate_handler.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
@ -93,24 +93,21 @@ void f2( std::size_t i, std::size_t n )
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
f1( 0, 3 );
|
||||
f2( 4, 3 );
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
std::cerr << boost::diagnostic_information( x ) << std::endl;
|
||||
}
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
|
||||
f1( 0, 3 );
|
||||
f2( 4, 3 );
|
||||
}
|
||||
----
|
||||
|
||||
Sample output:
|
||||
|
||||
```none
|
||||
example.cpp(31): Throw in function void f2(std::size_t, std::size_t)
|
||||
Dynamic exception type: boost::wrapexcept<std::out_of_range>
|
||||
std::exception::what: Index out of range: 4 >= 3
|
||||
std::terminate called after throwing an exception:
|
||||
|
||||
type: boost::wrapexcept<std::out_of_range>
|
||||
what(): Index out of range: 4 >= 3
|
||||
location: <source>:31:34 in function 'f2'
|
||||
```
|
||||
|
||||
## Using boost::throw_with_location
|
||||
|
@ -130,7 +130,8 @@ template<class E> boost::source_location get_throw_location( E const & e );
|
||||
```
|
||||
|
||||
Requires: :: `E` must be polymorphic.
|
||||
Effects: :: If `e` is a subobject of the object thrown by
|
||||
`boost::throw_with_location( x, loc )`, returns `loc`. Otherwise, returns
|
||||
a default constructed source location.
|
||||
Effects: ::
|
||||
* If `e` is a subobject of the object thrown by `boost::throw_with_location( x, loc )`, returns `loc`.
|
||||
* If `dynamic_cast<boost::exception const*>( e )` returns a nonzero value, returns the source location stored in that `boost::exception` subobject, if any.
|
||||
* Otherwise, returns a default constructed source location.
|
||||
|
||||
|
@ -54,7 +54,7 @@ typedef char (&wrapexcept_s2)[ 2 ];
|
||||
template<class T> wrapexcept_s1 wrapexcept_is_convertible( T* );
|
||||
template<class T> wrapexcept_s2 wrapexcept_is_convertible( void* );
|
||||
|
||||
template<class E, class B, std::size_t I = sizeof( wrapexcept_is_convertible<B>( static_cast< E* >( 0 ) ) ) > struct wrapexcept_add_base;
|
||||
template<class E, class B, std::size_t I = sizeof( wrapexcept_is_convertible<B>( static_cast< E* >( BOOST_NULLPTR ) ) ) > struct wrapexcept_add_base;
|
||||
|
||||
template<class E, class B> struct wrapexcept_add_base<E, B, 1>
|
||||
{
|
||||
@ -116,7 +116,7 @@ public:
|
||||
|
||||
boost::exception_detail::copy_boost_exception( p, this );
|
||||
|
||||
del.p_ = 0;
|
||||
del.p_ = BOOST_NULLPTR;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user