forked from boostorg/throw_exception
Compare commits
117 Commits
boost-1.65
...
develop
Author | SHA1 | Date | |
---|---|---|---|
f2b7655016 | |||
68d092f4d7 | |||
26f3ce3c5c | |||
e14f6ed69e | |||
3c67fc2b54 | |||
cffa8cd68c | |||
8608fdd923 | |||
b3a7f8e178 | |||
3e51d32285 | |||
f2ca8df9ab | |||
3470506880 | |||
c5dfcc3dd4 | |||
7b314a2184 | |||
dbbbb71232 | |||
d0f136e079 | |||
8c7b14f68b | |||
37ad7254d2 | |||
f6055628e6 | |||
65eddbb2f0 | |||
121c1407fd | |||
5eff93e41b | |||
8787d13e65 | |||
0a922307ec | |||
9ca27bddfc | |||
1d555aff4b | |||
b432f24664 | |||
9f6a2e7b89 | |||
95e02ea52b | |||
834a4f04dc | |||
ad30f163ef | |||
b1f6a8b25f | |||
264ee74b64 | |||
5b675bbc9c | |||
9c0a5b810b | |||
5e6223c838 | |||
f3b43b5679 | |||
397bc3d675 | |||
6360fb6f36 | |||
bd5f6a255f | |||
9f37f214ed | |||
3144a406d4 | |||
3d08795778 | |||
e0e262cc01 | |||
da6f5420fe | |||
924eb33335 | |||
37f7c5fd30 | |||
a9ea585926 | |||
548084bd4c | |||
237c7a35d6 | |||
3cd085a324 | |||
50a43b9512 | |||
e452a9ee16 | |||
86e09cc261 | |||
914d5a2ad3 | |||
9c6c409ada | |||
38d5273ad7 | |||
cab10beccd | |||
36f998f9b2 | |||
bc6f095b3d | |||
ac72b396f5 | |||
9e8a607ad9 | |||
fdf6b240f5 | |||
81e3072d04 | |||
fe38fbc5cf | |||
26bc9374e2 | |||
a2a78f6e46 | |||
c58f418c2f | |||
6458a1de40 | |||
ea9bd58f8c | |||
f477e33259 | |||
8a1382d6bf | |||
915a1dc49b | |||
eec2255703 | |||
970f826a75 | |||
2522bb5617 | |||
dad5cb4ed3 | |||
43a57d518c | |||
e2e802e508 | |||
5143552817 | |||
1e507924ce | |||
50c34dee24 | |||
37dfb7fe92 | |||
9dfba607d9 | |||
074bc77efb | |||
9d5b953dcf | |||
eafb1c877b | |||
dd7d2a273c | |||
9b99dd5f60 | |||
322d7611af | |||
56dd1c4111 | |||
a732dfad3c | |||
6845ba892d | |||
a17f4bad42 | |||
c807ae9201 | |||
fe0f62bf17 | |||
4714760035 | |||
72564448cf | |||
7e2f1b4ecd | |||
9d43946812 | |||
ca46976908 | |||
2fdcaa3be1 | |||
3fba666bea | |||
376fc078b5 | |||
614cbc4f34 | |||
ee45839a78 | |||
e3b556a978 | |||
8b879067f7 | |||
40e067d7b7 | |||
940df3e051 | |||
4fd6f2aa0e | |||
aec4ca6914 | |||
10f3663798 | |||
f796dd892a | |||
f5022b5ca8 | |||
a0ca8113fd | |||
56d65d5f62 | |||
cce19ef60f |
281
.drone.jsonnet
Normal file
281
.drone.jsonnet
Normal file
@ -0,0 +1,281 @@
|
||||
# Copyright 2022 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
local library = "throw_exception";
|
||||
|
||||
local triggers =
|
||||
{
|
||||
branch: [ "master", "develop", "feature/*" ]
|
||||
};
|
||||
|
||||
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
|
||||
local asan = { ASAN: '1' };
|
||||
|
||||
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
trigger: triggers,
|
||||
platform:
|
||||
{
|
||||
os: "linux",
|
||||
arch: arch
|
||||
},
|
||||
steps:
|
||||
[
|
||||
{
|
||||
name: "everything",
|
||||
image: image,
|
||||
environment: environment,
|
||||
commands:
|
||||
[
|
||||
'set -e',
|
||||
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
|
||||
] +
|
||||
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
|
||||
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
|
||||
[
|
||||
'export LIBRARY=' + library,
|
||||
'./.drone/drone.sh',
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "exec",
|
||||
trigger: triggers,
|
||||
platform: {
|
||||
"os": "darwin",
|
||||
"arch": arch
|
||||
},
|
||||
node: {
|
||||
"os": osx_version
|
||||
},
|
||||
steps: [
|
||||
{
|
||||
name: "everything",
|
||||
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
|
||||
commands:
|
||||
[
|
||||
'export LIBRARY=' + library,
|
||||
'./.drone/drone.sh',
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
{
|
||||
name: name,
|
||||
kind: "pipeline",
|
||||
type: "docker",
|
||||
trigger: triggers,
|
||||
platform:
|
||||
{
|
||||
os: "windows",
|
||||
arch: arch
|
||||
},
|
||||
"steps":
|
||||
[
|
||||
{
|
||||
name: "everything",
|
||||
image: image,
|
||||
environment: environment,
|
||||
commands:
|
||||
[
|
||||
'cmd /C .drone\\\\drone.bat ' + library,
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.4",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
|
||||
"g++-4.4",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.6",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x' },
|
||||
"g++-4.6",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.7",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x' },
|
||||
"g++-4.7",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.8*",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.9",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
|
||||
"g++-4.9",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 5*",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 6",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' },
|
||||
"g++-6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 7* 32/64",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 8",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' },
|
||||
"g++-8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 32",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9 ARM64 32/64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
arch="arm64",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32 ASAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan,
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 64 ASAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan,
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.5",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
|
||||
"clang-3.5",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.6",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
|
||||
"clang-3.6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
|
||||
"clang-3.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
|
||||
"clang-3.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 13",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
|
||||
"clang-13",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 UBSAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2017 msvc-14.1",
|
||||
"cppalliance/dronevs2017",
|
||||
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2019 msvc-14.2",
|
||||
"cppalliance/dronevs2019",
|
||||
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2022 msvc-14.3",
|
||||
"cppalliance/dronevs2022:1",
|
||||
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
|
||||
),
|
||||
]
|
23
.drone/drone.bat
Normal file
23
.drone/drone.bat
Normal file
@ -0,0 +1,23 @@
|
||||
@REM Copyright 2022 Peter Dimov
|
||||
@REM Distributed under the Boost Software License, Version 1.0.
|
||||
@REM https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@ECHO ON
|
||||
|
||||
set LIBRARY=%1
|
||||
set DRONE_BUILD_DIR=%CD%
|
||||
|
||||
set BOOST_BRANCH=develop
|
||||
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/boostdep
|
||||
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
|
||||
python tools/boostdep/depinst/depinst.py %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
24
.drone/drone.sh
Executable file
24
.drone/drone.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2022 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
BOOST_BRANCH=develop
|
||||
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
|
||||
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
git submodule update --init tools/boostdep
|
||||
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
|
||||
python tools/boostdep/depinst/depinst.py $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
206
.github/workflows/ci.yml
vendored
Normal file
206
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
- 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-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-10
|
||||
- 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-18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
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"
|
||||
os: ubuntu-18.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
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
|
||||
|
||||
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
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
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
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
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
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/.vscode/ipch/*
|
385
.travis.yml
Normal file
385
.travis.yml
Normal file
@ -0,0 +1,385 @@
|
||||
# Copyright 2016-2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-bionic-7
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-bionic-8
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-11
|
||||
env: TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-12
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-12
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
|
||||
- os: linux
|
||||
env: CMAKE=1
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=throw_exception ..
|
||||
- ctest --output-on-failure -R boost_throw_exception
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_SUBDIR=1
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
|
||||
script:
|
||||
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_INSTALL=1
|
||||
script:
|
||||
- pip install --user cmake
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=throw_exception -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build . --target install
|
||||
- cd ../libs/throw_exception/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/throw_exception
|
||||
- python tools/boostdep/depinst/depinst.py throw_exception
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j 3 libs/throw_exception/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
23
CMakeLists.txt
Normal file
23
CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(boost_throw_exception VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
add_library(boost_throw_exception INTERFACE)
|
||||
add_library(Boost::throw_exception ALIAS boost_throw_exception)
|
||||
|
||||
target_include_directories(boost_throw_exception INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_throw_exception
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
endif()
|
70
appveyor.yml
Normal file
70
appveyor.yml
Normal file
@ -0,0 +1,70 @@
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
version: 1.0.{build}-{branch}
|
||||
|
||||
shallow_clone: true
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
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
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
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-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/boostdep
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\throw_exception\
|
||||
- python tools/boostdep/depinst/depinst.py throw_exception
|
||||
- cmd /c bootstrap
|
||||
- b2 -d0 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/throw_exception/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
2
doc/.gitignore
vendored
Normal file
2
doc/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/html/
|
||||
/pdf/
|
@ -1,55 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
|
||||
<title>BOOST_THROW_EXCEPTION</title>
|
||||
<link href='reno.css' type='text/css' rel='stylesheet'/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body-0">
|
||||
<div class="body-1">
|
||||
<div class="body-2">
|
||||
<div>
|
||||
<div id="boost_logo">
|
||||
<a href="http://www.boost.org"><img style="border:0" src="../../../boost.png" alt="Boost" width="277" height="86"/></a>
|
||||
</div>
|
||||
<h1>Boost Exception</h1>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>BOOST_THROW_EXCEPTION</h3>
|
||||
</div>
|
||||
<div class="RenoIncludeDIV"><p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_throw_exception_hpp.html">boost/throw_exception.hpp</a></span>></p>
|
||||
<div class="RenoIncludeDIV"><pre>#if !defined( BOOST_EXCEPTION_DISABLE )
|
||||
#include <<span class="RenoLink"><a href="boost_exception_exception_hpp.html">boost/exception/exception.hpp</a></span>>
|
||||
#include <boost/current_function.hpp>
|
||||
#define <span class="RenoLink">BOOST_THROW_EXCEPTION</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
|
||||
#define <span class="RenoLink">BOOST_THROW_EXCEPTION</span>(x) ::boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>(x)
|
||||
#endif</pre>
|
||||
</div></div><p>This macro takes an exception object, records the current function name, __FILE__ and __LINE__ in it, and forwards it to <span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>. To recover this information at the catch site, use <span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span>; the information is also included in the message returned by <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>.</p>
|
||||
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
||||
See also: <span class="RenoPageList"><a href="boost-exception.html">Boost Exception</a> | <a href="boost_throw_exception_hpp.html">boost/throw_exception.hpp</a> | <a href="configuration_macros.html">Configuration Macros</a> | <a href="frequently_asked_questions.html">Frequently Asked Questions</a></span>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div id="footer">
|
||||
<p>
|
||||
<a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
|
||||
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
|
||||
<small>Copyright (c) 2006-2009 by Emil Dotchevski and Reverge Studios, Inc.<br/>
|
||||
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
23
doc/Jamfile
Normal file
23
doc/Jamfile
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright 2017 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import asciidoctor ;
|
||||
|
||||
html throw_exception.html : index.adoc ;
|
||||
|
||||
install html_ : throw_exception.html : <location>html ;
|
||||
|
||||
pdf throw_exception.pdf : index.adoc ;
|
||||
explicit throw_exception.pdf ;
|
||||
|
||||
install pdf_ : throw_exception.pdf : <location>pdf ;
|
||||
explicit pdf_ ;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : html_ ;
|
||||
explicit boostrelease ;
|
@ -1,65 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
|
||||
<title>boost/throw_exception.hpp</title>
|
||||
<link href='reno.css' type='text/css' rel='stylesheet'/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body-0">
|
||||
<div class="body-1">
|
||||
<div class="body-2">
|
||||
<div>
|
||||
<div id="boost_logo">
|
||||
<a href="http://www.boost.org"><img style="border:0" src="../../../boost.png" alt="Boost" width="277" height="86"/></a>
|
||||
</div>
|
||||
<h1>Boost Exception</h1>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h2>boost/throw_exception.hpp</h2>
|
||||
</div>
|
||||
<h3>Synopsis</h3>
|
||||
<div class="RenoIncludeDIV"><div class="RenoIncludeDIV"><pre><span class="RenoIncludeSPAN">#if !defined( BOOST_EXCEPTION_DISABLE )
|
||||
#include <<span class="RenoLink"><a href="boost_exception_exception_hpp.html">boost/exception/exception.hpp</a></span>>
|
||||
#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
|
||||
#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>(x)
|
||||
#endif</span>
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
<span class="RenoIncludeSPAN">#ifdef BOOST_NO_EXCEPTIONS
|
||||
void <span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>( std::exception const & e ); // user defined
|
||||
#else
|
||||
template <class E>
|
||||
void <span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span>( E const & e );
|
||||
#endif</span>
|
||||
}</pre>
|
||||
</div></div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
||||
See also: <span class="RenoPageList"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a> | <a href="configuration_macros.html">Configuration Macros</a> | <a href="synopsis.html">Synopsis</a> | <a href="throw_exception.html">throw_exception</a></span>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div id="footer">
|
||||
<p>
|
||||
<a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
|
||||
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
|
||||
<small>Copyright (c) 2006-2009 by Emil Dotchevski and Reverge Studios, Inc.<br/>
|
||||
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
24
doc/changes.adoc
Normal file
24
doc/changes.adoc
Normal file
@ -0,0 +1,24 @@
|
||||
////
|
||||
Copyright 2019, 2022 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
|
||||
[#changes]
|
||||
# Revision History
|
||||
:toc:
|
||||
:toc-title:
|
||||
:idprefix:
|
||||
|
||||
## Changes in 1.79.0
|
||||
|
||||
* Added `boost::throw_with_location`, a more lightweight alternative of
|
||||
`BOOST_THROW_EXCEPTION` for programs that do not use Boost.Exception.
|
||||
|
||||
## Changes in 1.73.0
|
||||
|
||||
* Added an overload of `throw_exception` that takes a `boost::source_location`
|
||||
object.
|
||||
|
||||
NOTE: Projects using `BOOST_THROW_EXCEPTION` with exceptions disabled will need
|
||||
to add a definition of this new overload.
|
50
doc/description.adoc
Normal file
50
doc/description.adoc
Normal file
@ -0,0 +1,50 @@
|
||||
////
|
||||
Copyright 2019, 2022 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
|
||||
[#description]
|
||||
# Description
|
||||
:toc:
|
||||
:toc-title:
|
||||
:idprefix:
|
||||
|
||||
The header `<boost/throw_exception.hpp>` provides a common Boost infrastructure
|
||||
for throwing exceptions, in the form of a function `boost::throw_exception`
|
||||
and a macro `BOOST_THROW_EXCEPTION`.
|
||||
|
||||
`boost::throw_exception(x);` is a replacement for `throw x;` that both
|
||||
degrades gracefully when exception handling support is not available, and
|
||||
integrates the thrown exception into facilities provided by
|
||||
link:../../../exception/index.html[Boost.Exception], such as automatically
|
||||
providing a base class of type `boost::exception` and support for
|
||||
`boost::exception_ptr`.
|
||||
|
||||
When exception handling is not available, the function is only declared, but
|
||||
not defined. This allows users to provide their own definition.
|
||||
|
||||
An overload for `boost::throw_exception` that takes a
|
||||
link:../../../assert/doc/html/assert.html#source_location_support[`boost::source_location`]
|
||||
is provided. It records the supplied source location into the `boost::exception`
|
||||
base class, from where it can later be retrieved when the exception is caught.
|
||||
link:../../../exception/doc/diagnostic_information.html[`boost::diagnostic_information`]
|
||||
automatically displays the stored source location.
|
||||
|
||||
The macro `BOOST_THROW_EXCEPTION(x)` expands to
|
||||
`::boost::throw_exception(x, BOOST_CURRENT_LOCATION)`, passing the current source
|
||||
location.
|
||||
|
||||
When integration with Boost.Exception and `boost::exception_ptr` is not needed,
|
||||
the function `boost::throw_with_location` can be used instead. It also throws
|
||||
a user-provided exception, associating it with a supplied or inferred source
|
||||
location, but does not supply the `boost::exception` base class and does not
|
||||
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.
|
218
doc/examples.adoc
Normal file
218
doc/examples.adoc
Normal file
@ -0,0 +1,218 @@
|
||||
////
|
||||
Copyright 2019, 2022 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
|
||||
[#examples]
|
||||
# Examples
|
||||
:toc:
|
||||
:toc-title:
|
||||
:idprefix:
|
||||
|
||||
## Using BOOST_THROW_EXCEPTION
|
||||
|
||||
Demonstrates the use of `BOOST_THROW_EXCEPTION`.
|
||||
|
||||
[source,c++,linenums,highlight=8]
|
||||
----
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/diagnostic_information.hpp>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
void f()
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( std::runtime_error( "Unspecified runtime error" ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
f();
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
std::cerr << boost::diagnostic_information( x ) << std::endl;
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Sample output:
|
||||
|
||||
```none
|
||||
example.cpp(8): Throw in function void f()
|
||||
Dynamic exception type: boost::wrapexcept<std::runtime_error>
|
||||
std::exception::what: Unspecified runtime error
|
||||
```
|
||||
|
||||
## Using boost::throw_exception with a source location
|
||||
|
||||
Demonstrates moving the call to `boost::throw_exception` to a common
|
||||
helper function that can be marked `BOOST_NOINLINE` to avoid
|
||||
unnecessary code duplication. The source location is passed
|
||||
explicitly to the helper function so that it can still record the
|
||||
logical throw point, instead of always pointing into the helper.
|
||||
|
||||
[source,c++,linenums,highlight=31]
|
||||
----
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/core/verbose_terminate_handler.hpp>
|
||||
#include <stdexcept>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_NORETURN BOOST_NOINLINE
|
||||
void throw_index_error( std::size_t i, std::size_t n,
|
||||
boost::source_location const & loc )
|
||||
{
|
||||
std::string msg = "Index out of range: "
|
||||
+ boost::lexical_cast<std::string>( i ) + " >= "
|
||||
+ boost::lexical_cast<std::string>( n );
|
||||
|
||||
boost::throw_exception( std::out_of_range( msg ), loc );
|
||||
}
|
||||
|
||||
void f1( std::size_t i, std::size_t n )
|
||||
{
|
||||
if( i >= n )
|
||||
{
|
||||
throw_index_error( i, n, BOOST_CURRENT_LOCATION );
|
||||
}
|
||||
}
|
||||
|
||||
void f2( std::size_t i, std::size_t n )
|
||||
{
|
||||
if( i >= n )
|
||||
{
|
||||
throw_index_error( i, n, BOOST_CURRENT_LOCATION );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
|
||||
f1( 0, 3 );
|
||||
f2( 4, 3 );
|
||||
}
|
||||
----
|
||||
|
||||
Sample output:
|
||||
|
||||
```none
|
||||
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
|
||||
|
||||
This example demonstrates a trivial use of `boost::throw_with_location`. Since
|
||||
a source location is not supplied, the location of the call to
|
||||
`boost::throw_with_location` is implicitly captured.
|
||||
|
||||
[source,c++,linenums,highlight=9]
|
||||
----
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/verbose_terminate_handler.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
int f1( int x )
|
||||
{
|
||||
if( x < 0 )
|
||||
{
|
||||
boost::throw_with_location(
|
||||
std::invalid_argument( "f1: x cannot be negative" ) );
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
|
||||
return f1( -4 );
|
||||
}
|
||||
----
|
||||
|
||||
Sample output:
|
||||
|
||||
```none
|
||||
std::terminate called after throwing an exception:
|
||||
|
||||
type: boost::detail::with_throw_location<std::invalid_argument>
|
||||
what(): f1: x cannot be negative
|
||||
location: <source>:9:9 in function 'f1'
|
||||
```
|
||||
|
||||
## Using boost::throw_with_location with an explicit source location
|
||||
|
||||
In this example, the call to `boost::throw_with_location` is moved into
|
||||
a common helper function. Note how the "API" functions `f1` and `f2`
|
||||
take a source location argument that defaults to `BOOST_CURRENT_LOCATION`.
|
||||
This allows the source location attached to the exception to point at
|
||||
the location of the call to `f2`, rather than inside of `f2`.
|
||||
|
||||
Since functions such as `f2` are typically called from more than one place
|
||||
in the program, this is usually what we want, because it enables us to
|
||||
identify the throwing call, rather than merely to know that it was `f2`
|
||||
that threw.
|
||||
|
||||
[source,c++,linenums,highlight=38]
|
||||
----
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/verbose_terminate_handler.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
BOOST_NORETURN BOOST_NOINLINE
|
||||
void throw_invalid_argument( char const * msg,
|
||||
boost::source_location const & loc )
|
||||
{
|
||||
boost::throw_with_location( std::invalid_argument( msg ), loc );
|
||||
}
|
||||
|
||||
int f1( int x,
|
||||
boost::source_location const & loc = BOOST_CURRENT_LOCATION )
|
||||
{
|
||||
if( x < 0 )
|
||||
{
|
||||
throw_invalid_argument( "f1: x cannot be negative", loc );
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int f2( int x,
|
||||
boost::source_location const & loc = BOOST_CURRENT_LOCATION )
|
||||
{
|
||||
if( x < 0 )
|
||||
{
|
||||
throw_invalid_argument( "f2: x cannot be negative", loc );
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::set_terminate( boost::core::verbose_terminate_handler );
|
||||
|
||||
return f1( 3 ) + f2( -11 );
|
||||
}
|
||||
----
|
||||
|
||||
Sample output:
|
||||
|
||||
```none
|
||||
std::terminate called after throwing an exception:
|
||||
|
||||
type: boost::detail::with_throw_location<std::invalid_argument>
|
||||
what(): f2: x cannot be negative
|
||||
location: <source>:38:22 in function 'main'
|
||||
```
|
9
doc/index-docinfo-footer.html
Normal file
9
doc/index-docinfo-footer.html
Normal file
@ -0,0 +1,9 @@
|
||||
<style>
|
||||
|
||||
*:not(pre)>code { background: none; color: #600000; }
|
||||
:not(pre):not([class^=L])>code { background: none; color: #600000; }
|
||||
|
||||
pre.rouge .hll { background-color: #ffd; }
|
||||
pre.rouge .hll * { background-color: initial; }
|
||||
|
||||
</style>
|
30
doc/index.adoc
Normal file
30
doc/index.adoc
Normal file
@ -0,0 +1,30 @@
|
||||
////
|
||||
Copyright 2017, 2019, 2022 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
|
||||
# Boost.ThrowException
|
||||
Peter Dimov, Emil Dotchevski
|
||||
:toc: left
|
||||
:idprefix:
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
include::description.adoc[]
|
||||
include::examples.adoc[]
|
||||
include::changes.adoc[]
|
||||
include::reference.adoc[]
|
||||
|
||||
:leveloffset: -1
|
||||
|
||||
[appendix]
|
||||
## Copyright and License
|
||||
|
||||
This documentation is
|
||||
|
||||
* Copyright 2019, 2022 Peter Dimov
|
||||
* Distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].
|
137
doc/reference.adoc
Normal file
137
doc/reference.adoc
Normal file
@ -0,0 +1,137 @@
|
||||
////
|
||||
Copyright 2019 Peter Dimov
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
http://www.boost.org/LICENSE_1_0.txt
|
||||
////
|
||||
|
||||
[#reference]
|
||||
# Reference
|
||||
:toc:
|
||||
:toc-title:
|
||||
:idprefix:
|
||||
|
||||
[#synopsis]
|
||||
## <boost/throw_exception.hpp> Synopsis
|
||||
|
||||
```
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined
|
||||
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e,
|
||||
boost::source_location const & loc ); // user defined
|
||||
|
||||
#else
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e );
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e,
|
||||
boost::source_location const & loc );
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#define BOOST_THROW_EXCEPTION(x) \
|
||||
::boost::throw_exception(x, BOOST_CURRENT_LOCATION)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_with_location( E && e,
|
||||
boost::source_location const & loc = BOOST_CURRENT_LOCATION );
|
||||
|
||||
template<class E> boost::source_location get_throw_location( E const & e );
|
||||
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
## throw_exception
|
||||
|
||||
```
|
||||
#if defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined
|
||||
|
||||
#else
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e );
|
||||
|
||||
#endif
|
||||
```
|
||||
|
||||
Requires: :: `E` must have `std::exception` as a public and unambiguous base
|
||||
class.
|
||||
|
||||
Effects: ::
|
||||
* When exceptions aren't available, the function is declared, but
|
||||
not defined. The user is expected to supply an appropriate definition.
|
||||
* Otherwise, if `BOOST_EXCEPTION_DISABLE` is defined, the function
|
||||
throws `e`.
|
||||
* Otherwise, the function throws an object of a type derived from `E`,
|
||||
derived from `boost::exception`, if `E` doesn't already derive from
|
||||
it, and containing the necessary support for `boost::exception_ptr`.
|
||||
|
||||
```
|
||||
#if defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e,
|
||||
boost::source_location const & loc ); // user defined
|
||||
|
||||
#else
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e,
|
||||
boost::source_location const & loc );
|
||||
|
||||
#endif
|
||||
```
|
||||
|
||||
Requires: :: `E` must have `std::exception` as a public and unambiguous base
|
||||
class.
|
||||
|
||||
Effects: ::
|
||||
* When exceptions aren't available, the function is declared, but
|
||||
not defined. The user is expected to supply an appropriate definition.
|
||||
* Otherwise, if `BOOST_EXCEPTION_DISABLE` is defined, the function
|
||||
throws `e`.
|
||||
* Otherwise, the function throws an object of a type derived from `E`,
|
||||
derived from `boost::exception`, if `E` doesn't already derive from
|
||||
it, and containing the necessary support for `boost::exception_ptr`. The
|
||||
`boost::exception` base class is initialized to contain the source
|
||||
location `loc`.
|
||||
|
||||
## throw_with_location
|
||||
|
||||
```
|
||||
template<class E> BOOST_NORETURN void throw_with_location( E && e,
|
||||
boost::source_location const & loc = BOOST_CURRENT_LOCATION );
|
||||
```
|
||||
|
||||
Requires: :: `std::decay<E>::type` must have `std::exception` as a public
|
||||
and unambiguous base class.
|
||||
|
||||
Effects: ::
|
||||
* When exceptions aren't available, `boost::throw_exception( e, loc );`
|
||||
* Otherwise, the function throws an object of a type derived from `E`,
|
||||
such that, if this object `x` is caught as `std::exception` or `E`,
|
||||
`boost::get_throw_location( x )` would return `loc`.
|
||||
|
||||
## get_throw_location
|
||||
|
||||
```
|
||||
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`.
|
||||
* 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.
|
||||
|
226
doc/reno.css
226
doc/reno.css
@ -1,226 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
body
|
||||
{
|
||||
font-family: Trebuchet, Verdana, Arial, Helvetica, Sans;
|
||||
font-size: 10pt;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.RenoPageList,
|
||||
ol,
|
||||
ul
|
||||
{
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.RenoPageList
|
||||
{
|
||||
margin:0;
|
||||
}
|
||||
|
||||
h1
|
||||
{
|
||||
font-size: 24pt;
|
||||
clear: left;
|
||||
padding-top: 5pt;
|
||||
padding-bottom: 5pt;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h2
|
||||
{
|
||||
font-size: 18pt;
|
||||
clear: left;
|
||||
padding-top: 20pt;
|
||||
padding-bottom: 5pt;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h3
|
||||
{
|
||||
font-size: 14pt;
|
||||
clear: left;
|
||||
padding-top: 15pt;
|
||||
padding-bottom: 5pt;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
h4
|
||||
{
|
||||
font-size: 10pt;
|
||||
float: left;
|
||||
clear: left;
|
||||
padding-top: 5pt;
|
||||
padding-bottom: 0;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-right: 4pt;
|
||||
}
|
||||
|
||||
p
|
||||
{
|
||||
font-size: 10pt;
|
||||
padding-top: 5pt;
|
||||
padding-bottom: 5pt;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
clear:right;
|
||||
}
|
||||
|
||||
pre
|
||||
{
|
||||
border-top: 1px solid #C5C5C5;
|
||||
border-bottom: 1px solid #C5C5C5;
|
||||
border-left: 1px solid #C5C5C5;
|
||||
border-right: 1px solid #C5C5C5;
|
||||
font-size: 10pt;
|
||||
padding-top: 5pt;
|
||||
padding-bottom: 5pt;
|
||||
padding-left: 5pt;
|
||||
padding-right: 5pt;
|
||||
margin-left: 18pt;
|
||||
margin-right: 18pt;
|
||||
margin-top: 10pt;
|
||||
margin-bottom: 10pt;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
ol,ul
|
||||
{
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ul li
|
||||
{
|
||||
padding-top: 5pt;
|
||||
padding-bottom: 5pt;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.RenoIndex h3
|
||||
{
|
||||
margin: 20pt 0 5pt 0;
|
||||
padding: 2pt;
|
||||
display: inline;
|
||||
border: 1.5pt solid #A0A0A0;
|
||||
float: left;
|
||||
clear: both;
|
||||
width: 15pt;
|
||||
text-align: center;
|
||||
background-color: #EAEAEA;
|
||||
}
|
||||
|
||||
.RenoIndex p
|
||||
{
|
||||
clear: both;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.RenoHookUnbound,
|
||||
.RenoHookBound
|
||||
{
|
||||
background-position: left center;
|
||||
background-image: url('link.gif');
|
||||
background-repeat: no-repeat;
|
||||
padding-left: 10pt;
|
||||
}
|
||||
|
||||
.RenoIncludeDIV
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.RenoError
|
||||
{
|
||||
background-color: red;
|
||||
color: white;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
text-decoration: underline;
|
||||
color: #0000AA;
|
||||
}
|
||||
|
||||
tt
|
||||
{
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: 0;
|
||||
color: black;
|
||||
background-color: black;
|
||||
height: 1px;
|
||||
margin-top: 20pt;
|
||||
}
|
||||
|
||||
blockquote
|
||||
{
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 20pt;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#boost_logo
|
||||
{
|
||||
float:right;
|
||||
}
|
||||
|
||||
#footer
|
||||
{
|
||||
margin-top:20pt;
|
||||
}
|
||||
|
||||
.logo_pic
|
||||
{
|
||||
border:0;
|
||||
}
|
||||
|
||||
.logo
|
||||
{
|
||||
float:right;
|
||||
margin-left: 6pt;
|
||||
margin-right: -4pt;
|
||||
}
|
||||
|
||||
.body-0
|
||||
{
|
||||
min-width: 40em;
|
||||
padding-left: 30px;
|
||||
background: url(shade-l.png) repeat-y left;
|
||||
}
|
||||
.body-1
|
||||
{
|
||||
padding-right: 30px;
|
||||
background: url(shade-r.png) repeat-y right;
|
||||
}
|
||||
.body-2
|
||||
{
|
||||
background-color: white;
|
||||
padding: 0 8pt 0 8pt;
|
||||
margin-left: 0;
|
||||
border-top: solid 2.5pt #717171;
|
||||
border-bottom: solid 3pt #717171;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
||||
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
||||
<head>
|
||||
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
|
||||
<title>throw_exception</title>
|
||||
<link href='reno.css' type='text/css' rel='stylesheet'/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="body-0">
|
||||
<div class="body-1">
|
||||
<div class="body-2">
|
||||
<div>
|
||||
<div id="boost_logo">
|
||||
<a href="http://www.boost.org"><img style="border:0" src="../../../boost.png" alt="Boost" width="277" height="86"/></a>
|
||||
</div>
|
||||
<h1>Boost Exception</h1>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>throw_exception</h3>
|
||||
</div>
|
||||
<div class="RenoIncludeDIV"><p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_throw_exception_hpp.html">boost/throw_exception.hpp</a></span>></p>
|
||||
<pre>namespace
|
||||
boost
|
||||
{
|
||||
<span class="RenoIncludeSPAN">#ifdef BOOST_NO_EXCEPTIONS
|
||||
void <span class="RenoLink">throw_exception</span>( std::exception const & e ); // user defined
|
||||
#else
|
||||
template <class E>
|
||||
void <span class="RenoLink">throw_exception</span>( E const & e );
|
||||
#endif</span>
|
||||
}</pre>
|
||||
</div><h4>Effects:</h4>
|
||||
<div><ul><li> If BOOST_NO_EXCEPTIONS is not defined, boost::<span class="RenoLink">throw_exception</span>(e) throws an exception of unspecified type that derives publicly from E and from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>.</li>
|
||||
<li> If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of <span class="RenoLink">throw_exception</span> are allowed to assume that the function never returns; therefore, if the user-defined <span class="RenoLink">throw_exception</span> returns, the behavior is undefined.</li>
|
||||
</ul></div>
|
||||
<h4>Requirements:</h4>
|
||||
<p>E must derive publicly from std::exception. E may or may not derive from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>.</p>
|
||||
<h4>Notes:</h4>
|
||||
<div><ul><li> The emitted exception can be intercepted as E &, std::exception &, or boost::exception &.</li>
|
||||
<li> The emitted exception supports boost::<span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span>.</li>
|
||||
<li> If BOOST_EXCEPTION_DISABLE is defined and BOOST_NO_EXCEPTIONS is not defined, boost::<span class="RenoLink">throw_exception</span>(e) equivalent to throw e.</li>
|
||||
</ul></div>
|
||||
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
||||
See also: <span class="RenoPageList"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION</a> | <a href="boost-exception.html">Boost Exception</a> | <a href="boost_throw_exception_hpp.html">boost/throw_exception.hpp</a> | <a href="configuration_macros.html">Configuration Macros</a> | <a href="enable_current_exception.html">enable_current_exception</a> | <a href="frequently_asked_questions.html">Frequently Asked Questions</a> | <a href="tutorial_exception_ptr.html">Transporting of Exceptions Between Threads</a></span>
|
||||
</div>
|
||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||
<div id="footer">
|
||||
<p>
|
||||
<a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
|
||||
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
|
||||
<small>Copyright (c) 2006-2009 by Emil Dotchevski and Reverge Studios, Inc.<br/>
|
||||
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.7 KiB |
@ -3,23 +3,34 @@
|
||||
//Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||
#define UUID_274DA366004E11DCB1DDFE2E56D89593
|
||||
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma warning(push,1)
|
||||
#endif
|
||||
#ifndef BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
|
||||
#define BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
|
||||
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#ifdef BOOST_EXCEPTION_MINI_BOOST
|
||||
#include <memory>
|
||||
namespace boost { namespace exception_detail { using std::shared_ptr; } }
|
||||
#else
|
||||
namespace boost { template <class T> class shared_ptr; };
|
||||
namespace boost { template <class T> class shared_ptr; }
|
||||
namespace boost { namespace exception_detail { using boost::shared_ptr; } }
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#if __GNUC__*100+__GNUC_MINOR__>301
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
#ifdef __clang__
|
||||
#pragma clang system_header
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push,1)
|
||||
#pragma warning(disable: 4265)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
@ -97,6 +108,7 @@ boost
|
||||
typedef error_info<struct throw_function_,char const *> throw_function;
|
||||
typedef error_info<struct throw_file_,char const *> throw_file;
|
||||
typedef error_info<struct throw_line_,int> throw_line;
|
||||
typedef error_info<struct throw_column_,int> throw_column;
|
||||
|
||||
template <>
|
||||
class
|
||||
@ -140,17 +152,23 @@ boost
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility push (default)
|
||||
# endif
|
||||
#endif
|
||||
class exception;
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif
|
||||
template <>
|
||||
class
|
||||
error_info<throw_column_,int>
|
||||
{
|
||||
public:
|
||||
typedef int value_type;
|
||||
value_type v_;
|
||||
explicit
|
||||
error_info( value_type v ):
|
||||
v_(v)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
exception;
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
@ -170,7 +188,7 @@ boost
|
||||
|
||||
protected:
|
||||
|
||||
~error_info_container() throw()
|
||||
~error_info_container() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -187,6 +205,9 @@ boost
|
||||
template <>
|
||||
struct get_info<throw_line>;
|
||||
|
||||
template <>
|
||||
struct get_info<throw_column>;
|
||||
|
||||
template <class>
|
||||
struct set_info_rv;
|
||||
|
||||
@ -199,6 +220,9 @@ boost
|
||||
template <>
|
||||
struct set_info_rv<throw_line>;
|
||||
|
||||
template <>
|
||||
struct set_info_rv<throw_column>;
|
||||
|
||||
char const * get_diagnostic_information( exception const &, char const * );
|
||||
|
||||
void copy_boost_exception( exception *, exception const * );
|
||||
@ -214,14 +238,15 @@ boost
|
||||
|
||||
template <class E>
|
||||
E const & set_info( E const &, throw_line const & );
|
||||
|
||||
template <class E>
|
||||
E const & set_info( E const &, throw_column const & );
|
||||
|
||||
boost::source_location get_exception_throw_location( exception const & );
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility push (default)
|
||||
# endif
|
||||
#endif
|
||||
class
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
exception
|
||||
{
|
||||
//<N3757>
|
||||
@ -235,23 +260,25 @@ boost
|
||||
exception():
|
||||
throw_function_(0),
|
||||
throw_file_(0),
|
||||
throw_line_(-1)
|
||||
throw_line_(-1),
|
||||
throw_column_(-1)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef __HP_aCC
|
||||
//On HP aCC, this protected copy constructor prevents throwing boost::exception.
|
||||
//On all other platforms, the same effect is achieved by the pure virtual destructor.
|
||||
exception( exception const & x ) throw():
|
||||
exception( exception const & x ) BOOST_NOEXCEPT_OR_NOTHROW:
|
||||
data_(x.data_),
|
||||
throw_function_(x.throw_function_),
|
||||
throw_file_(x.throw_file_),
|
||||
throw_line_(x.throw_line_)
|
||||
throw_line_(x.throw_line_),
|
||||
throw_column_(x.throw_column_)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
virtual ~exception() throw()
|
||||
virtual ~exception() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
#ifndef __HP_aCC
|
||||
= 0 //Workaround for HP aCC, =0 incorrectly leads to link errors.
|
||||
#endif
|
||||
@ -271,37 +298,40 @@ boost
|
||||
template <class E>
|
||||
friend E const & exception_detail::set_info( E const &, throw_line const & );
|
||||
|
||||
template <class E>
|
||||
friend E const & exception_detail::set_info( E const &, throw_column const & );
|
||||
|
||||
template <class E,class Tag,class T>
|
||||
friend E const & exception_detail::set_info( E const &, error_info<Tag,T> const & );
|
||||
|
||||
friend char const * exception_detail::get_diagnostic_information( exception const &, char const * );
|
||||
|
||||
friend boost::source_location exception_detail::get_exception_throw_location( exception const & );
|
||||
|
||||
template <class>
|
||||
friend struct exception_detail::get_info;
|
||||
friend struct exception_detail::get_info<throw_function>;
|
||||
friend struct exception_detail::get_info<throw_file>;
|
||||
friend struct exception_detail::get_info<throw_line>;
|
||||
friend struct exception_detail::get_info<throw_column>;
|
||||
template <class>
|
||||
friend struct exception_detail::set_info_rv;
|
||||
friend struct exception_detail::set_info_rv<throw_function>;
|
||||
friend struct exception_detail::set_info_rv<throw_file>;
|
||||
friend struct exception_detail::set_info_rv<throw_line>;
|
||||
friend struct exception_detail::set_info_rv<throw_column>;
|
||||
friend void exception_detail::copy_boost_exception( exception *, exception const * );
|
||||
#endif
|
||||
mutable exception_detail::refcount_ptr<exception_detail::error_info_container> data_;
|
||||
mutable char const * throw_function_;
|
||||
mutable char const * throw_file_;
|
||||
mutable int throw_line_;
|
||||
mutable int throw_column_;
|
||||
};
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
inline
|
||||
exception::
|
||||
~exception() throw()
|
||||
~exception() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
}
|
||||
|
||||
@ -331,6 +361,42 @@ boost
|
||||
x.throw_line_=y.v_;
|
||||
return x;
|
||||
}
|
||||
|
||||
template <class E>
|
||||
E const &
|
||||
set_info( E const & x, throw_column const & y )
|
||||
{
|
||||
x.throw_column_=y.v_;
|
||||
return x;
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template <>
|
||||
struct
|
||||
set_info_rv<throw_column>
|
||||
{
|
||||
template <class E>
|
||||
static
|
||||
E const &
|
||||
set( E const & x, throw_column && y )
|
||||
{
|
||||
x.throw_column_=y.v_;
|
||||
return x;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
inline boost::source_location get_exception_throw_location( exception const & x )
|
||||
{
|
||||
return boost::source_location(
|
||||
x.throw_file_? x.throw_file_: "",
|
||||
x.throw_line_ >= 0? x.throw_line_: 0,
|
||||
x.throw_function_? x.throw_function_: "",
|
||||
x.throw_column_ >= 0? x.throw_column_: 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -338,13 +404,9 @@ boost
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility push (default)
|
||||
# endif
|
||||
#endif
|
||||
template <class T>
|
||||
struct
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
error_info_injector:
|
||||
public T,
|
||||
public exception
|
||||
@ -355,15 +417,10 @@ boost
|
||||
{
|
||||
}
|
||||
|
||||
~error_info_injector() throw()
|
||||
~error_info_injector() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
}
|
||||
};
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
struct large_size { char c[256]; };
|
||||
large_size dispatch_boost_exception( exception const * );
|
||||
@ -407,16 +464,15 @@ boost
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
BOOST_NORETURN void throw_exception(std::exception const & e); // user defined
|
||||
#endif
|
||||
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility push (default)
|
||||
# endif
|
||||
#endif
|
||||
class
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
clone_base
|
||||
{
|
||||
public:
|
||||
@ -425,15 +481,10 @@ boost
|
||||
virtual void rethrow() const = 0;
|
||||
|
||||
virtual
|
||||
~clone_base() throw()
|
||||
~clone_base() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
}
|
||||
};
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
inline
|
||||
void
|
||||
@ -445,6 +496,7 @@ boost
|
||||
a->throw_file_ = b->throw_file_;
|
||||
a->throw_line_ = b->throw_line_;
|
||||
a->throw_function_ = b->throw_function_;
|
||||
a->throw_column_ = b->throw_column_;
|
||||
a->data_ = data;
|
||||
}
|
||||
|
||||
@ -454,13 +506,9 @@ boost
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility push (default)
|
||||
# endif
|
||||
#endif
|
||||
template <class T>
|
||||
class
|
||||
BOOST_SYMBOL_VISIBLE
|
||||
clone_impl:
|
||||
public T,
|
||||
public virtual clone_base
|
||||
@ -481,7 +529,7 @@ boost
|
||||
copy_boost_exception(this,&x);
|
||||
}
|
||||
|
||||
~clone_impl() throw()
|
||||
~clone_impl() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
}
|
||||
|
||||
@ -496,15 +544,14 @@ boost
|
||||
void
|
||||
rethrow() const
|
||||
{
|
||||
#if defined(BOOST_NO_EXCEPTIONS)
|
||||
boost::throw_exception(*this);
|
||||
#else
|
||||
throw*this;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4)
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
inline
|
||||
@ -518,4 +565,5 @@ boost
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
|
||||
|
@ -1,11 +1,5 @@
|
||||
#ifndef UUID_AA15E74A856F11E08B8D93F24824019B
|
||||
#define UUID_AA15E74A856F11E08B8D93F24824019B
|
||||
#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma warning(push,1)
|
||||
#endif
|
||||
#ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED
|
||||
#define BOOST_THROW_EXCEPTION_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
@ -13,90 +7,272 @@
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// boost/throw_exception.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2002, 2018-2022 Peter Dimov
|
||||
// Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// http://www.boost.org/libs/utility/throw_exception.html
|
||||
//
|
||||
// http://www.boost.org/libs/throw_exception
|
||||
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <exception>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) )
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) )
|
||||
# define BOOST_EXCEPTION_DISABLE
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 )
|
||||
# define BOOST_EXCEPTION_DISABLE
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE )
|
||||
# include <boost/exception/exception.hpp>
|
||||
#if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION)
|
||||
# include <boost/current_function.hpp>
|
||||
# define BOOST_THROW_EXCEPTION_CURRENT_FUNCTION BOOST_CURRENT_FUNCTION
|
||||
#endif
|
||||
# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_THROW_EXCEPTION_CURRENT_FUNCTION,__FILE__,__LINE__)
|
||||
#else
|
||||
# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x)
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
|
||||
void throw_exception( std::exception const & e ); // user defined
|
||||
#if defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
#else
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined
|
||||
BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_location const & loc ); // user defined
|
||||
|
||||
inline void throw_exception_assert_compatibility( std::exception const & ) { }
|
||||
|
||||
template<class E> BOOST_NORETURN inline void throw_exception( E const & e )
|
||||
{
|
||||
//All boost exceptions are required to derive from std::exception,
|
||||
//to ensure compatibility with BOOST_NO_EXCEPTIONS.
|
||||
throw_exception_assert_compatibility(e);
|
||||
|
||||
#ifndef BOOST_EXCEPTION_DISABLE
|
||||
throw enable_current_exception(enable_error_info(e));
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
|
||||
// boost::wrapexcept<E>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
typedef char (&wrapexcept_s1)[ 1 ];
|
||||
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> struct wrapexcept_add_base<E, B, 1>
|
||||
{
|
||||
struct type {};
|
||||
};
|
||||
|
||||
template<class E, class B> struct wrapexcept_add_base<E, B, 2>
|
||||
{
|
||||
typedef B type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept:
|
||||
public detail::wrapexcept_add_base<E, boost::exception_detail::clone_base>::type,
|
||||
public E,
|
||||
public detail::wrapexcept_add_base<E, boost::exception>::type
|
||||
{
|
||||
private:
|
||||
|
||||
struct deleter
|
||||
{
|
||||
wrapexcept * p_;
|
||||
~deleter() { delete p_; }
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
void copy_from( void const* )
|
||||
{
|
||||
}
|
||||
|
||||
void copy_from( boost::exception const* p )
|
||||
{
|
||||
static_cast<boost::exception&>( *this ) = *p;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit wrapexcept( E const & e ): E( e )
|
||||
{
|
||||
copy_from( &e );
|
||||
}
|
||||
|
||||
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e )
|
||||
{
|
||||
copy_from( &e );
|
||||
|
||||
set_info( *this, throw_file( loc.file_name() ) );
|
||||
set_info( *this, throw_line( loc.line() ) );
|
||||
set_info( *this, throw_function( loc.function_name() ) );
|
||||
set_info( *this, throw_column( loc.column() ) );
|
||||
}
|
||||
|
||||
virtual boost::exception_detail::clone_base const * clone() const BOOST_OVERRIDE
|
||||
{
|
||||
wrapexcept * p = new wrapexcept( *this );
|
||||
deleter del = { p };
|
||||
|
||||
boost::exception_detail::copy_boost_exception( p, this );
|
||||
|
||||
del.p_ = BOOST_NULLPTR;
|
||||
return p;
|
||||
}
|
||||
|
||||
virtual void rethrow() const BOOST_OVERRIDE
|
||||
{
|
||||
#if defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
boost::throw_exception( *this );
|
||||
|
||||
#else
|
||||
|
||||
throw *this;
|
||||
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
// All boost exceptions are required to derive from std::exception,
|
||||
// to ensure compatibility with BOOST_NO_EXCEPTIONS.
|
||||
|
||||
inline void throw_exception_assert_compatibility( std::exception const & ) {}
|
||||
|
||||
// boost::throw_exception
|
||||
|
||||
#if !defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
#if defined( BOOST_EXCEPTION_DISABLE )
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw e;
|
||||
}
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw e;
|
||||
}
|
||||
|
||||
#else // defined( BOOST_EXCEPTION_DISABLE )
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E>( e );
|
||||
}
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & loc )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw wrapexcept<E>( e, loc );
|
||||
}
|
||||
|
||||
#endif // defined( BOOST_EXCEPTION_DISABLE )
|
||||
|
||||
#endif // !defined( BOOST_NO_EXCEPTIONS )
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// BOOST_THROW_EXCEPTION
|
||||
|
||||
#define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x, BOOST_CURRENT_LOCATION)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// throw_with_location
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE throw_location
|
||||
{
|
||||
boost::source_location location_;
|
||||
|
||||
explicit throw_location( boost::source_location const & loc ): location_( loc )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class E> class BOOST_SYMBOL_VISIBLE with_throw_location: public E, public throw_location
|
||||
{
|
||||
public:
|
||||
|
||||
with_throw_location( E const & e, boost::source_location const & loc ): E( e ), throw_location( loc )
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
with_throw_location( E && e, boost::source_location const & loc ): E( std::move( e ) ), throw_location( loc )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_with_location( E && e, boost::source_location const & loc = BOOST_CURRENT_LOCATION )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw detail::with_throw_location<typename std::decay<E>::type>( std::forward<E>( e ), loc );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_with_location( E const & e, boost::source_location const & loc = BOOST_CURRENT_LOCATION )
|
||||
{
|
||||
throw_exception_assert_compatibility( e );
|
||||
throw detail::with_throw_location<E>( e, loc );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_EXCEPTION_DISABLE )
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
template <class E>
|
||||
BOOST_NORETURN
|
||||
void
|
||||
throw_exception_( E const & x, char const * current_function, char const * file, int line )
|
||||
{
|
||||
boost::throw_exception(
|
||||
set_info(
|
||||
set_info(
|
||||
set_info(
|
||||
enable_error_info(x),
|
||||
throw_function(current_function)),
|
||||
throw_file(file)),
|
||||
throw_line(line)));
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
template<class E> BOOST_NORETURN void throw_with_location( E const & e, boost::source_location const & loc = BOOST_CURRENT_LOCATION )
|
||||
{
|
||||
boost::throw_exception( e, loc );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// get_throw_location
|
||||
|
||||
template<class E> boost::source_location get_throw_location( E const & e )
|
||||
{
|
||||
#if defined(BOOST_NO_RTTI)
|
||||
|
||||
(void)e;
|
||||
return boost::source_location();
|
||||
|
||||
#else
|
||||
|
||||
if( detail::throw_location const* pl = dynamic_cast< detail::throw_location const* >( &e ) )
|
||||
{
|
||||
return pl->location_;
|
||||
}
|
||||
else if( boost::exception const* px = dynamic_cast< boost::exception const* >( &e ) )
|
||||
{
|
||||
return exception_detail::get_exception_throw_location( *px );
|
||||
}
|
||||
else
|
||||
{
|
||||
return boost::source_location();
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif
|
||||
#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED
|
||||
|
@ -1,13 +1,13 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv=refresh content="0; URL=../exception/doc/boost_throw_exception_hpp.html">
|
||||
<meta http-equiv=refresh content="0; URL=doc/html/throw_exception.html">
|
||||
<title>Automatic redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
Automatic redirection failed, please go to
|
||||
<a href="../exception/doc/boost_throw_exception_hpp.html">boost_throw_exception_hpp.html</a>. <hr>
|
||||
<p>© Copyright Beman Dawes, 2001</p>
|
||||
<a href="doc/html/throw_exception.html">throw_exception.html</a>. <hr>
|
||||
<p>Copyright Beman Dawes, 2001</p>
|
||||
<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy
|
||||
at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||
|
@ -2,13 +2,17 @@
|
||||
"key": "throw_exception",
|
||||
"name": "ThrowException",
|
||||
"authors": [
|
||||
"Emil Dotchevski"
|
||||
"Emil Dotchevski",
|
||||
"Peter Dimov"
|
||||
],
|
||||
"maintainers": [
|
||||
"Emil Dotchevski <emil -at- revergestudios.com>"
|
||||
"Emil Dotchevski <emil -at- revergestudios.com>",
|
||||
"Peter Dimov <pdimov -at- gmail.com>"
|
||||
],
|
||||
"description": "A common infrastructure for throwing exceptions from Boost libraries.",
|
||||
"category": [
|
||||
"Miscellaneous"
|
||||
]
|
||||
"Emulation",
|
||||
"Error-handling"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
17
test/CMakeLists.txt
Normal file
17
test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
|
||||
|
||||
if(HAVE_BOOST_TEST)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::throw_exception Boost::core Boost::exception)
|
||||
|
||||
endif()
|
||||
|
||||
#run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>static : throw_from_library_static ;
|
||||
#run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>shared : throw_from_library_shared ;
|
||||
|
||||
#run throw_exception_nx_test.cpp : : : <exception-handling>off ;
|
||||
#run throw_exception_nx_test2.cpp : : : <exception-handling>off ;
|
@ -1,21 +1,56 @@
|
||||
# Boost Exception Library test Jamfile
|
||||
# Boost ThrowException Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
||||
# Copyright 2019 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<link>static
|
||||
<exception-handling>on
|
||||
;
|
||||
project : requirements
|
||||
<warnings>extra
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>gcc:<cxxflags>-Wshadow ;
|
||||
|
||||
run throw_exception_test.cpp ;
|
||||
run throw_exception_no_exceptions_test.cpp ;
|
||||
run throw_exception_no_integration_test.cpp ;
|
||||
run throw_exception_no_both_test.cpp ;
|
||||
|
||||
compile-fail throw_exception_fail.cpp ;
|
||||
compile-fail throw_exception_fail.cpp
|
||||
: <warnings-as-errors>off ;
|
||||
|
||||
run throw_exception_test2.cpp ;
|
||||
run throw_exception_test3.cpp ;
|
||||
run throw_exception_test4.cpp ;
|
||||
run throw_exception_test5.cpp ;
|
||||
|
||||
lib lib1_throw : lib1_throw.cpp : <define>LIB1_SOURCE=1 <link>shared:<define>LIB1_DYN_LINK=1 : : <link>shared:<define>LIB1_DYN_LINK=1 ;
|
||||
lib lib2_throw : lib2_throw.cpp : <define>LIB2_SOURCE=1 <link>shared:<define>LIB2_DYN_LINK=1 : : <link>shared:<define>LIB2_DYN_LINK=1 ;
|
||||
lib lib3_throw : lib3_throw.cpp : <define>LIB3_SOURCE=1 <link>shared:<define>LIB3_DYN_LINK=1 : : <link>shared:<define>LIB3_DYN_LINK=1 ;
|
||||
lib lib4_throw : lib4_throw.cpp : <define>LIB4_SOURCE=1 <link>shared:<define>LIB4_DYN_LINK=1 : : <link>shared:<define>LIB4_DYN_LINK=1 ;
|
||||
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw : : : <link>static : throw_from_library_static ;
|
||||
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw : : : <link>shared : throw_from_library_shared ;
|
||||
|
||||
run throw_exception_nx_test.cpp : : : <exception-handling>off ;
|
||||
run throw_exception_nx_test2.cpp : : : <exception-handling>off ;
|
||||
run throw_exception_nx_test3.cpp : : : <exception-handling>off ;
|
||||
|
||||
run make_exception_ptr_test.cpp ;
|
||||
run make_exception_ptr_test2.cpp ;
|
||||
|
||||
run make_exception_ptr_nx_test.cpp : : : <exception-handling>off ;
|
||||
run make_exception_ptr_nx_test2.cpp : : : <exception-handling>off ;
|
||||
|
||||
run throw_with_location_test.cpp ;
|
||||
run throw_with_location_test2.cpp ;
|
||||
run throw_with_location_test3.cpp ;
|
||||
run throw_with_location_test4.cpp ;
|
||||
|
||||
run throw_with_location_nx_test.cpp : : : <exception-handling>off ;
|
||||
|
||||
run throw_with_location_test3.cpp : : : <rtti>off : throw_with_location_test3_nr ;
|
||||
|
17
test/cmake_install_test/CMakeLists.txt
Normal file
17
test/cmake_install_test/CMakeLists.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_throw_exception REQUIRED)
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::throw_exception)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME main COMMAND main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
19
test/cmake_install_test/main.cpp
Normal file
19
test/cmake_install_test/main.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::throw_exception( std::runtime_error( "" ) );
|
||||
return 1;
|
||||
}
|
||||
catch( std::runtime_error const& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
19
test/cmake_subdir_test/CMakeLists.txt
Normal file
19
test/cmake_subdir_test/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright 2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::throw_exception)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME main COMMAND main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
19
test/cmake_subdir_test/main.cpp
Normal file
19
test/cmake_subdir_test/main.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::throw_exception( std::runtime_error( "" ) );
|
||||
return 1;
|
||||
}
|
||||
catch( std::runtime_error const& )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
13
test/lib1_throw.cpp
Normal file
13
test/lib1_throw.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "lib1_throw.hpp"
|
||||
|
||||
void lib1::f()
|
||||
{
|
||||
throw lib1::exception();
|
||||
}
|
35
test/lib1_throw.hpp
Normal file
35
test/lib1_throw.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef LIB1_THROW_HPP_INCLUDED
|
||||
#define LIB1_THROW_HPP_INCLUDED
|
||||
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB1_DYN_LINK)
|
||||
# if defined(LIB1_SOURCE)
|
||||
# define LIB1_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB1_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB1_DECL
|
||||
#endif
|
||||
|
||||
namespace lib1
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB1_DECL void f();
|
||||
|
||||
} // namespace lib1
|
||||
|
||||
#endif // #ifndef LIB1_THROW_HPP_INCLUDED
|
14
test/lib2_throw.cpp
Normal file
14
test/lib2_throw.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "lib2_throw.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
void lib2::f()
|
||||
{
|
||||
boost::throw_exception( lib2::exception() );
|
||||
}
|
35
test/lib2_throw.hpp
Normal file
35
test/lib2_throw.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef LIB2_THROW_HPP_INCLUDED
|
||||
#define LIB2_THROW_HPP_INCLUDED
|
||||
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB2_DYN_LINK)
|
||||
# if defined(LIB2_SOURCE)
|
||||
# define LIB2_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB2_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB2_DECL
|
||||
#endif
|
||||
|
||||
namespace lib2
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB2_DECL void f();
|
||||
|
||||
} // namespace lib2
|
||||
|
||||
#endif // #ifndef LIB2_THROW_HPP_INCLUDED
|
14
test/lib3_throw.cpp
Normal file
14
test/lib3_throw.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "lib3_throw.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
void lib3::f()
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( lib3::exception() );
|
||||
}
|
35
test/lib3_throw.hpp
Normal file
35
test/lib3_throw.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef LIB3_THROW_HPP_INCLUDED
|
||||
#define LIB3_THROW_HPP_INCLUDED
|
||||
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB3_DYN_LINK)
|
||||
# if defined(LIB3_SOURCE)
|
||||
# define LIB3_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB3_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB3_DECL
|
||||
#endif
|
||||
|
||||
namespace lib3
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB3_DECL void f();
|
||||
|
||||
} // namespace lib3
|
||||
|
||||
#endif // #ifndef LIB3_THROW_HPP_INCLUDED
|
14
test/lib4_throw.cpp
Normal file
14
test/lib4_throw.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2018, 2022 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "lib4_throw.hpp"
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
void lib4::f()
|
||||
{
|
||||
boost::throw_with_location( lib4::exception() );
|
||||
}
|
35
test/lib4_throw.hpp
Normal file
35
test/lib4_throw.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef LIB4_THROW_HPP_INCLUDED
|
||||
#define LIB4_THROW_HPP_INCLUDED
|
||||
|
||||
// Copyright 2018, 2022 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <exception>
|
||||
|
||||
#if defined(LIB4_DYN_LINK)
|
||||
# if defined(LIB4_SOURCE)
|
||||
# define LIB4_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define LIB4_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define LIB4_DECL
|
||||
#endif
|
||||
|
||||
namespace lib4
|
||||
{
|
||||
|
||||
struct BOOST_SYMBOL_VISIBLE exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
LIB4_DECL void f();
|
||||
|
||||
} // namespace lib4
|
||||
|
||||
#endif // #ifndef LIB4_THROW_HPP_INCLUDED
|
29
test/make_exception_ptr_nx_test.cpp
Normal file
29
test/make_exception_ptr_nx_test.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/exception_ptr.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::make_exception_ptr( my_exception() );
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// shared_ptr needs this
|
||||
void throw_exception( std::exception const & )
|
||||
{
|
||||
std::exit( 1 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
31
test/make_exception_ptr_nx_test2.cpp
Normal file
31
test/make_exception_ptr_nx_test2.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#define BOOST_EXCEPTION_DISABLE
|
||||
|
||||
#include <boost/exception_ptr.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::make_exception_ptr( my_exception() );
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
// shared_ptr needs this
|
||||
void throw_exception( std::exception const & )
|
||||
{
|
||||
std::exit( 1 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
18
test/make_exception_ptr_test.cpp
Normal file
18
test/make_exception_ptr_test.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception );
|
||||
return boost::report_errors();
|
||||
}
|
20
test/make_exception_ptr_test2.cpp
Normal file
20
test/make_exception_ptr_test2.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#define BOOST_EXCEPTION_DISABLE
|
||||
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( boost::make_exception_ptr( my_exception() ) ), my_exception );
|
||||
return boost::report_errors();
|
||||
}
|
@ -5,27 +5,28 @@
|
||||
|
||||
#define BOOST_NO_EXCEPTIONS
|
||||
#define BOOST_EXCEPTION_DISABLE
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
bool called=false;
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
void
|
||||
throw_exception( std::exception const & )
|
||||
{
|
||||
called=true;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
boost::throw_exception( my_exception() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
boost::throw_exception(my_exception());
|
||||
BOOST_TEST(called);
|
||||
return boost::report_errors();
|
||||
}
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const & )
|
||||
{
|
||||
std::exit( 0 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
@ -4,27 +4,28 @@
|
||||
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_NO_EXCEPTIONS
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
bool called=false;
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
namespace
|
||||
boost
|
||||
{
|
||||
void
|
||||
throw_exception( std::exception const & )
|
||||
{
|
||||
called=true;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
boost::throw_exception( my_exception() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
boost::throw_exception(my_exception());
|
||||
BOOST_TEST(called);
|
||||
return boost::report_errors();
|
||||
}
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const & )
|
||||
{
|
||||
std::exit( 0 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
@ -5,7 +5,11 @@
|
||||
|
||||
#define BOOST_EXCEPTION_DISABLE
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
|
||||
|
30
test/throw_exception_nx_test.cpp
Normal file
30
test/throw_exception_nx_test.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::throw_exception( my_exception() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const & )
|
||||
{
|
||||
std::exit( 0 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
36
test/throw_exception_nx_test2.cpp
Normal file
36
test/throw_exception_nx_test2.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2019 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const &, boost::source_location const & loc )
|
||||
{
|
||||
int r = 0;
|
||||
|
||||
if( std::strcmp( loc.file_name(), __FILE__ ) != 0 ) ++r;
|
||||
if( loc.line() != 19 ) ++r;
|
||||
|
||||
std::exit( r );
|
||||
}
|
||||
|
||||
} // namespace boost
|
18
test/throw_exception_nx_test3.cpp
Normal file
18
test/throw_exception_nx_test3.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
// Make sure that simple inclusion does not
|
||||
// require boost::throw_exception to be defined
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
@ -4,10 +4,13 @@
|
||||
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception { };
|
||||
|
||||
int
|
||||
|
38
test/throw_exception_test2.cpp
Normal file
38
test/throw_exception_test2.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception3: public std::exception, public virtual boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception() ), boost::exception );
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), boost::exception );
|
||||
BOOST_TEST_THROWS( boost::throw_exception( my_exception3() ), boost::exception );
|
||||
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception() ), boost::exception );
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception );
|
||||
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), boost::exception );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
111
test/throw_exception_test3.cpp
Normal file
111
test/throw_exception_test3.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"
|
||||
# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor"
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception3: public std::exception, public virtual boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::throw_exception( my_exception() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boost::throw_exception( 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 ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boost::throw_exception( 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 ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), my_exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( 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 ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( 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 ), boost::exception );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
118
test/throw_exception_test4.cpp
Normal file
118
test/throw_exception_test4.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <cstring>
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception3: public std::exception, public virtual boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
char const* translate_function( char const * fn, char const * cfn )
|
||||
{
|
||||
// translate "" and "main" to BOOST_CURRENT_FUNCTION
|
||||
return fn[0] == 0 || std::strcmp( fn, "main" ) == 0? cfn: fn;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
char const * const * file = boost::get_error_info<boost::throw_file>( x );
|
||||
|
||||
BOOST_TEST( file != 0 );
|
||||
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
|
||||
}
|
||||
|
||||
{
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 35 );
|
||||
}
|
||||
|
||||
{
|
||||
char const * const * function = boost::get_error_info<boost::throw_function>( x );
|
||||
|
||||
BOOST_TEST( function != 0 );
|
||||
BOOST_TEST_CSTR_EQ( translate_function( *function, BOOST_CURRENT_FUNCTION ), BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception2() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
char const * const * file = boost::get_error_info<boost::throw_file>( x );
|
||||
|
||||
BOOST_TEST( file != 0 );
|
||||
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
|
||||
}
|
||||
|
||||
{
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 63 );
|
||||
}
|
||||
|
||||
{
|
||||
char const * const * function = boost::get_error_info<boost::throw_function>( x );
|
||||
|
||||
BOOST_TEST( function != 0 );
|
||||
BOOST_TEST_CSTR_EQ( translate_function( *function, BOOST_CURRENT_FUNCTION ), BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception3() );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
char const * const * file = boost::get_error_info<boost::throw_file>( x );
|
||||
|
||||
BOOST_TEST( file != 0 );
|
||||
BOOST_TEST_CSTR_EQ( *file, __FILE__ );
|
||||
}
|
||||
|
||||
{
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 91 );
|
||||
}
|
||||
|
||||
{
|
||||
char const * const * function = boost::get_error_info<boost::throw_function>( x );
|
||||
|
||||
BOOST_TEST( function != 0 );
|
||||
BOOST_TEST_CSTR_EQ( translate_function( *function, BOOST_CURRENT_FUNCTION ), BOOST_CURRENT_FUNCTION );
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
119
test/throw_exception_test5.cpp
Normal file
119
test/throw_exception_test5.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
// Copyright 2018, 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"
|
||||
# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor"
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/exception/info.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
typedef boost::error_info<struct tag_error_code, int> error_code;
|
||||
typedef boost::error_info<struct tag_error_string, std::string> error_string;
|
||||
|
||||
class my_exception: public std::exception, public boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
class my_exception2: public std::exception, public virtual boost::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::throw_exception( my_exception() << error_code( 123 ) << error_string( "error%%string" ) );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
int const * code = boost::get_error_info<error_code>( x );
|
||||
|
||||
BOOST_TEST( code != 0 );
|
||||
BOOST_TEST_EQ( *code, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::string const * str = boost::get_error_info<error_string>( x );
|
||||
|
||||
BOOST_TEST( str != 0 );
|
||||
BOOST_TEST_EQ( *str, "error%%string" );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception() << error_code( 123 ) << error_string( "error%%string" ) );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
int const * code = boost::get_error_info<error_code>( x );
|
||||
|
||||
BOOST_TEST( code != 0 );
|
||||
BOOST_TEST_EQ( *code, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::string const * str = boost::get_error_info<error_string>( x );
|
||||
|
||||
BOOST_TEST( str != 0 );
|
||||
BOOST_TEST_EQ( *str, "error%%string" );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boost::throw_exception( my_exception2() << error_code( 123 ) << error_string( "error%%string" ) );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
int const * code = boost::get_error_info<error_code>( x );
|
||||
|
||||
BOOST_TEST( code != 0 );
|
||||
BOOST_TEST_EQ( *code, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::string const * str = boost::get_error_info<error_string>( x );
|
||||
|
||||
BOOST_TEST( str != 0 );
|
||||
BOOST_TEST_EQ( *str, "error%%string" );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( my_exception2() << error_code( 123 ) << error_string( "error%%string" ) );
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
{
|
||||
int const * code = boost::get_error_info<error_code>( x );
|
||||
|
||||
BOOST_TEST( code != 0 );
|
||||
BOOST_TEST_EQ( *code, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
std::string const * str = boost::get_error_info<error_string>( x );
|
||||
|
||||
BOOST_TEST( str != 0 );
|
||||
BOOST_TEST_EQ( *str, "error%%string" );
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
112
test/throw_from_library_test.cpp
Normal file
112
test/throw_from_library_test.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
# pragma clang diagnostic ignored "-Wpotentially-evaluated-expression"
|
||||
# pragma clang diagnostic ignored "-Wdelete-non-abstract-non-virtual-dtor"
|
||||
# pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
#include "lib1_throw.hpp"
|
||||
#include "lib2_throw.hpp"
|
||||
#include "lib3_throw.hpp"
|
||||
#include "lib4_throw.hpp"
|
||||
#include <boost/exception/exception.hpp>
|
||||
#include <boost/exception_ptr.hpp>
|
||||
#include <boost/exception/get_error_info.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
void test_catch_by_type()
|
||||
{
|
||||
BOOST_TEST_THROWS( lib1::f(), lib1::exception );
|
||||
BOOST_TEST_THROWS( lib2::f(), lib2::exception );
|
||||
BOOST_TEST_THROWS( lib3::f(), lib3::exception );
|
||||
BOOST_TEST_THROWS( lib4::f(), lib4::exception );
|
||||
}
|
||||
|
||||
void test_catch_by_exception()
|
||||
{
|
||||
BOOST_TEST_THROWS( lib2::f(), boost::exception );
|
||||
BOOST_TEST_THROWS( lib3::f(), boost::exception );
|
||||
}
|
||||
|
||||
void test_exception_ptr()
|
||||
{
|
||||
try
|
||||
{
|
||||
lib2::f();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib2::exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lib3::f();
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
boost::exception_ptr p = boost::current_exception();
|
||||
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception );
|
||||
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
|
||||
}
|
||||
}
|
||||
|
||||
void test_throw_line()
|
||||
{
|
||||
try
|
||||
{
|
||||
lib3::f();
|
||||
}
|
||||
catch( boost::exception const & x )
|
||||
{
|
||||
int const * line = boost::get_error_info<boost::throw_line>( x );
|
||||
|
||||
BOOST_TEST( line != 0 );
|
||||
BOOST_TEST_EQ( *line, 13 );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "lib3::f failed to throw boost::exception" );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
lib4::f();
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_NE( loc.line(), 0u );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "lib4::f failed to throw std::exception" );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_catch_by_type();
|
||||
test_catch_by_exception();
|
||||
test_exception_ptr();
|
||||
test_throw_line();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
30
test/throw_with_location_nx_test.cpp
Normal file
30
test/throw_with_location_nx_test.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2019, 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
# pragma warning(disable: 4577) // noexcept used without /EHsc
|
||||
# pragma warning(disable: 4530) // C++ exception handler used
|
||||
#endif
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
class my_exception: public std::exception {};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::throw_with_location( my_exception() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
void throw_exception( std::exception const &, boost::source_location const & )
|
||||
{
|
||||
std::exit( 0 );
|
||||
}
|
||||
|
||||
} // namespace boost
|
22
test/throw_with_location_test.cpp
Normal file
22
test/throw_with_location_test.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_THROWS( boost::throw_with_location( my_exception() ), my_exception );
|
||||
BOOST_TEST_THROWS( boost::throw_with_location( my_exception() ), std::exception );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
64
test/throw_with_location_test2.cpp
Normal file
64
test/throw_with_location_test2.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::throw_with_location( my_exception() );
|
||||
|
||||
BOOST_ERROR( "boost::throw_with_location failed to throw" );
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
// When not supplied explicitly, the source location is best effort.
|
||||
// It should be the location of the throw_with_location call on
|
||||
// recent compilers, but that's not guaranteed for every compiler.
|
||||
// So we can't be more specific in testing it.
|
||||
|
||||
BOOST_TEST_CSTR_NE( loc.file_name(), "" );
|
||||
BOOST_TEST_NE( loc.line(), 0u );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "boost::throw_with_location failed to throw std::exception" );
|
||||
}
|
||||
|
||||
boost::source_location location = BOOST_CURRENT_LOCATION;
|
||||
|
||||
try
|
||||
{
|
||||
boost::throw_with_location( my_exception(), location );
|
||||
|
||||
BOOST_ERROR( "boost::throw_with_location failed to throw" );
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), location.file_name() );
|
||||
BOOST_TEST_CSTR_EQ( loc.function_name(), location.function_name() );
|
||||
BOOST_TEST_EQ( loc.line(), location.line() );
|
||||
BOOST_TEST_EQ( loc.column(), location.column() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "boost::throw_with_location failed to throw std::exception" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
33
test/throw_with_location_test3.cpp
Normal file
33
test/throw_with_location_test3.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
throw my_exception();
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), "" );
|
||||
BOOST_TEST_CSTR_EQ( loc.function_name(), "" );
|
||||
BOOST_TEST_EQ( loc.line(), 0u );
|
||||
BOOST_TEST_EQ( loc.column(), 0u );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
41
test/throw_with_location_test4.cpp
Normal file
41
test/throw_with_location_test4.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
|
||||
class my_exception: public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::source_location location = BOOST_CURRENT_LOCATION;
|
||||
|
||||
try
|
||||
{
|
||||
boost::throw_exception( my_exception(), location );
|
||||
|
||||
BOOST_ERROR( "boost::throw_exception failed to throw" );
|
||||
}
|
||||
catch( std::exception const & x )
|
||||
{
|
||||
boost::source_location loc = boost::get_throw_location( x );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( loc.file_name(), location.file_name() );
|
||||
BOOST_TEST_CSTR_EQ( loc.function_name(), location.function_name() );
|
||||
BOOST_TEST_EQ( loc.line(), location.line() );
|
||||
BOOST_TEST_EQ( loc.column(), location.column() );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
BOOST_ERROR( "boost::throw_exception failed to throw std::exception" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user