Compare commits

..

11 Commits

28 changed files with 395 additions and 1596 deletions

View File

@ -1,324 +0,0 @@
# 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 16.04 GCC 4.4",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
"g++-4.4",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 16.04 GCC 4.6",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x' },
"g++-4.6",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 16.04 GCC 4.7",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x' },
"g++-4.7",
),
linux_pipeline(
"Linux 16.04 GCC 4.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '03,11' },
"g++-4.8",
),
linux_pipeline(
"Linux 16.04 GCC 4.9",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
"g++-4.9",
),
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/64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 20.04 GCC 9* ARM64",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
arch="arm64",
),
linux_pipeline(
"Linux 20.04 GCC 9* S390x",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
arch="s390x",
),
linux_pipeline(
"Linux 20.04 GCC 10 32/64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' },
"g++-10-multilib",
),
linux_pipeline(
"Linux 22.04 GCC 11* 32/64",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 22.04 GCC 12 32/64 ASAN",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + asan,
"g++-12-multilib",
),
linux_pipeline(
"Linux 23.04 GCC 13 32/64 UBSAN",
"cppalliance/droneubuntu2304:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + ubsan,
"g++-13-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 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
"clang-13",
),
linux_pipeline(
"Linux 22.04 Clang 14",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' },
"clang-14",
),
linux_pipeline(
"Linux 22.04 Clang 15",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
"clang-15",
),
linux_pipeline(
"Linux 23.04 Clang 16",
"cppalliance/droneubuntu2304:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
"clang-16",
),
linux_pipeline(
"Linux 23.10 Clang 17 UBSAN",
"cppalliance/droneubuntu2310:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
"clang-17",
),
linux_pipeline(
"Linux 23.10 Clang 17 ASAN",
"cppalliance/droneubuntu2310:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-17",
),
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,
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + ubsan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
windows_pipeline(
"Windows VS2015 msvc-14.0",
"cppalliance/dronevs2015",
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
),
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' },
),
]

View File

@ -1,23 +0,0 @@
@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

View File

@ -1,25 +0,0 @@
#!/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
export PATH=~/.local/bin:/usr/local/bin:$PATH
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}

View File

@ -19,26 +19,22 @@ jobs:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: g++-4.8
- toolset: gcc-5
cxxstd: "03,11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: g++-5
- toolset: gcc-6
cxxstd: "03,11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: g++-6
- toolset: gcc-7
cxxstd: "03,11,14,17"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
os: ubuntu-18.04
install: g++-8
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
@ -49,48 +45,32 @@ jobs:
install: g++-10
- toolset: gcc-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04
- toolset: gcc-12
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12
- toolset: gcc-13
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:23.04
os: ubuntu-latest
install: g++-13
- toolset: gcc-14
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: g++-14
os: ubuntu-20.04
install: g++-11
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-20.04
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-20.04
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
@ -118,72 +98,17 @@ jobs:
os: ubuntu-20.04
install: clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:23.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:23.10
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "03,11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-12
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "03,11,14,17,20,2b"
os: macos-14
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
container: ${{matrix.container}}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
@ -203,7 +128,7 @@ jobs:
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
@ -222,20 +147,16 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: "14,latest"
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
cxxstd: "14,17,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,20,latest"
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
@ -246,7 +167,7 @@ jobs:
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
@ -274,346 +195,4 @@ jobs:
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
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- 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%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release

View File

@ -26,12 +26,12 @@ environment:
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14,17,latest
CXXSTD: 14,17
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
TOOLSET: msvc-14.2
CXXSTD: 14,17,latest
ADDRMD: 64
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
@ -67,4 +67,4 @@ 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 embed-manifest-via=linker
- b2 -j3 libs/throw_exception/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

View File

@ -1,5 +1,5 @@
////
Copyright 2019, 2022 Peter Dimov
Copyright 2019 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
////
@ -10,11 +10,6 @@ http://www.boost.org/LICENSE_1_0.txt
: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`

View File

@ -1,5 +1,5 @@
////
Copyright 2019, 2022 Peter Dimov
Copyright 2019 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
////
@ -35,16 +35,83 @@ 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.
[#examples]
# Examples
:toc:
:toc-title:
:idprefix:
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)`.
## Using BOOST_THROW_EXCEPTION
`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.
```
#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;
}
}
```
## Using boost::throw_exception with a source location
```
#include <boost/throw_exception.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <stdexcept>
#include <cstddef>
#include <iostream>
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()
{
try
{
f1( 4, 3 );
}
catch( std::exception const & x )
{
std::cerr << boost::diagnostic_information( x ) << std::endl;
}
}
```

View File

@ -1,218 +0,0 @@
////
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'
```

View File

@ -3,7 +3,4 @@
*: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>

View File

@ -1,5 +1,5 @@
////
Copyright 2017, 2019, 2022 Peter Dimov
Copyright 2017, 2019 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
http://www.boost.org/LICENSE_1_0.txt
////
@ -15,7 +15,6 @@ Peter Dimov, Emil Dotchevski
:leveloffset: +1
include::description.adoc[]
include::examples.adoc[]
include::changes.adoc[]
include::reference.adoc[]
@ -26,5 +25,5 @@ include::reference.adoc[]
This documentation is
* Copyright 2019, 2022 Peter Dimov
* Copyright 2019 Peter Dimov
* Distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@ -41,16 +41,6 @@ template<class E> BOOST_NORETURN void throw_exception( E const & e,
#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
@ -106,32 +96,3 @@ Effects: ::
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.

View File

@ -6,7 +6,6 @@
#ifndef BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
#define BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593
#include <boost/assert/source_location.hpp>
#include <boost/config.hpp>
#include <exception>
@ -19,7 +18,7 @@ namespace boost { namespace exception_detail { using boost::shared_ptr; } }
#endif
#if !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
#if defined(__GNUC__) && __GNUC__*100+__GNUC_MINOR__>301
#if __GNUC__*100+__GNUC_MINOR__>301
#pragma GCC system_header
#endif
#ifdef __clang__
@ -108,7 +107,6 @@ 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
@ -152,20 +150,6 @@ boost
}
};
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;
@ -205,9 +189,6 @@ boost
template <>
struct get_info<throw_line>;
template <>
struct get_info<throw_column>;
template <class>
struct set_info_rv;
@ -220,9 +201,6 @@ 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 * );
@ -238,11 +216,6 @@ 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 & );
}
class
@ -260,8 +233,7 @@ boost
exception():
throw_function_(0),
throw_file_(0),
throw_line_(-1),
throw_column_(-1)
throw_line_(-1)
{
}
@ -272,8 +244,7 @@ boost
data_(x.data_),
throw_function_(x.throw_function_),
throw_file_(x.throw_file_),
throw_line_(x.throw_line_),
throw_column_(x.throw_column_)
throw_line_(x.throw_line_)
{
}
#endif
@ -298,35 +269,27 @@ 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_;
};
inline
@ -361,42 +324,6 @@ 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
);
}
}
////////////////////////////////////////////////////////////////////////
@ -496,7 +423,6 @@ 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;
}

View File

@ -7,9 +7,10 @@
# pragma once
#endif
//
// boost/throw_exception.hpp
//
// Copyright (c) 2002, 2018-2022 Peter Dimov
// Copyright (c) 2002, 2018, 2019 Peter Dimov
// Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc.
//
// Distributed under the Boost Software License, Version 1.0. (See
@ -17,17 +18,14 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
// http://www.boost.org/libs/throw_exception
//
#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( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) )
# define BOOST_EXCEPTION_DISABLE
@ -43,18 +41,18 @@ BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_loc
#endif
// boost::wrapexcept<E>
namespace detail
{
// wrapexcept_add_base
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* >( BOOST_NULLPTR ) ) ) > struct wrapexcept_add_base;
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>
{
@ -66,12 +64,37 @@ template<class E, class B> struct wrapexcept_add_base<E, B, 2>
typedef B type;
};
// wrapexcept_location
struct wrapexcept_location
{
wrapexcept_location() {}
explicit wrapexcept_location( boost::source_location const& loc ): location_( loc ) {}
boost::source_location location_;
};
} // namespace detail
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept:
// wrapexcept<E>
#if !defined(BOOST_NO_CXX11_HDR_EXCEPTION)
template<class E, int cxxstd = 11> struct BOOST_SYMBOL_VISIBLE wrapexcept;
#else
template<class E, int cxxstd = 98> struct BOOST_SYMBOL_VISIBLE wrapexcept;
#endif
// C++98 version for backward compatibility
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept<E, 98>:
public detail::wrapexcept_add_base<E, boost::exception_detail::clone_base>::type,
public E,
public detail::wrapexcept_add_base<E, boost::exception>::type
public detail::wrapexcept_add_base<E, boost::exception>::type,
public detail::wrapexcept_location
{
private:
@ -99,14 +122,13 @@ public:
copy_from( &e );
}
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e )
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e ), detail::wrapexcept_location( loc )
{
copy_from( &e );
set_info( *this, throw_file( loc.file_name() ) );
set_info( *this, throw_line( static_cast<int>( loc.line() ) ) );
set_info( *this, throw_line( loc.line() ) );
set_info( *this, throw_function( loc.function_name() ) );
set_info( *this, throw_column( static_cast<int>( loc.column() ) ) );
}
virtual boost::exception_detail::clone_base const * clone() const BOOST_OVERRIDE
@ -116,7 +138,7 @@ public:
boost::exception_detail::copy_boost_exception( p, this );
del.p_ = BOOST_NULLPTR;
del.p_ = 0;
return p;
}
@ -134,6 +156,49 @@ public:
}
};
// C++11 version
template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept<E, 11>:
public E,
public detail::wrapexcept_location
{
private:
void copy_from( void const* )
{
}
void copy_from( boost::exception const* p )
{
static_cast<boost::exception&>( *this ) = *p;
}
template<class T> void set_info_impl( void*, T const& )
{
}
template<class T> void set_info_impl( boost::exception * p, T const& t )
{
exception_detail::set_info( *p, t );
}
public:
explicit wrapexcept( E const & e ): E( e )
{
copy_from( &e );
}
explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e ), detail::wrapexcept_location( loc )
{
copy_from( &e );
set_info_impl( this, throw_file( loc.file_name() ) );
set_info_impl( this, throw_line( loc.line() ) );
set_info_impl( this, throw_function( loc.function_name() ) );
}
};
// All boost exceptions are required to derive from std::exception,
// to ensure compatibility with BOOST_NO_EXCEPTIONS.
@ -157,122 +222,58 @@ template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::sourc
throw e;
}
#else // defined( BOOST_EXCEPTION_DISABLE )
#elif !defined(BOOST_NO_CXX11_HDR_EXCEPTION)
template<class E> BOOST_NORETURN void throw_exception( E const & e )
{
throw_exception_assert_compatibility( e );
throw wrapexcept<E>( e );
throw 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 );
throw wrapexcept<E, 11>( e, loc );
}
#else // C++98
template<class E> BOOST_NORETURN void throw_exception( E const & e )
{
throw_exception_assert_compatibility( e );
throw wrapexcept<E, 98>( 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, 98>( e, loc );
}
#endif // defined( BOOST_EXCEPTION_DISABLE )
#endif // !defined( BOOST_NO_EXCEPTIONS )
// get_throw_location
template<class E> boost::source_location get_throw_location( E const& e )
{
#if defined(BOOST_NO_RTTI)
return boost::source_location();
#else
detail::wrapexcept_location const* p = dynamic_cast< detail::wrapexcept_location const* >( &e );
return p? p->location_: boost::source_location();
#endif
}
} // 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
#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
#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED

View File

@ -8,20 +8,12 @@
import testing ;
local gcc-flags = -Wsign-promo -Wconversion -Wsign-conversion -Wshadow -Wundef ;
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>$(gcc-flags)
<toolset>clang:<cxxflags>$(gcc-flags)
;
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 ;
@ -35,14 +27,16 @@ run throw_exception_test2.cpp ;
run throw_exception_test3.cpp ;
run throw_exception_test4.cpp ;
run throw_exception_test5.cpp ;
run throw_exception_test6.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 ;
lib lib5_throw : lib5_throw.cpp : <define>LIB5_SOURCE=1 <link>shared:<define>LIB5_DYN_LINK=1 : : <link>shared:<define>LIB5_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 <target-os>darwin,<undefined-sanitizer>norecover:<build>no : throw_from_library_shared ;
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_throw : : : <link>static : throw_from_library_static ;
run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw lib4_throw lib5_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 ;
@ -53,12 +47,3 @@ 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 ;

View File

@ -1,4 +1,4 @@
// Copyright 2018, 2022 Peter Dimov
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
@ -10,5 +10,5 @@
void lib4::f()
{
boost::throw_with_location( lib4::exception() );
boost::throw_exception( lib4::exception() );
}

View File

@ -1,13 +1,14 @@
#ifndef LIB4_THROW_HPP_INCLUDED
#define LIB4_THROW_HPP_INCLUDED
// Copyright 2018, 2022 Peter Dimov
// 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/exception/exception.hpp>
#include <boost/config.hpp>
#include <exception>
@ -24,7 +25,7 @@
namespace lib4
{
struct BOOST_SYMBOL_VISIBLE exception: public std::exception
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
{
};

14
test/lib5_throw.cpp Normal file
View 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 "lib5_throw.hpp"
#include <boost/throw_exception.hpp>
void lib5::f()
{
BOOST_THROW_EXCEPTION( lib5::exception() );
}

36
test/lib5_throw.hpp Normal file
View File

@ -0,0 +1,36 @@
#ifndef LIB5_THROW_HPP_INCLUDED
#define LIB5_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/exception/exception.hpp>
#include <boost/config.hpp>
#include <exception>
#if defined(LIB5_DYN_LINK)
# if defined(LIB5_SOURCE)
# define LIB5_DECL BOOST_SYMBOL_EXPORT
# else
# define LIB5_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define LIB5_DECL
#endif
namespace lib5
{
struct BOOST_SYMBOL_VISIBLE exception: public std::exception, public boost::exception
{
};
LIB5_DECL void f();
} // namespace lib5
#endif // #ifndef LIB5_THROW_HPP_INCLUDED

View File

@ -26,12 +26,20 @@ 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_exception() ), my_exception );
BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), my_exception2 );
BOOST_TEST_THROWS( boost::throw_exception( my_exception2() ), boost::exception );
BOOST_TEST_THROWS( boost::throw_exception( my_exception3() ), my_exception3 );
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_exception() ), my_exception );
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), my_exception2 );
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception2() ), boost::exception );
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), my_exception3 );
BOOST_TEST_THROWS( BOOST_THROW_EXCEPTION( my_exception3() ), boost::exception );
return boost::report_errors();

View File

@ -44,7 +44,6 @@ int main()
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
@ -80,7 +79,6 @@ int main()
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

View File

@ -8,11 +8,6 @@
#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
{
@ -22,57 +17,8 @@ class my_exception3: public std::exception, public virtual boost::exception
{
};
char const* translate_function( char const * fn, char const * cfn )
{
// fn comes from BOOST_CURRENT_LOCATION, which is not necessarily the same as BOOST_CURRENT_FUNCTION
// so translate the known problematic cases to BOOST_CURRENT_FUNCTION to make the test pass
return fn[0] == 0 || std::strcmp( fn, "main" ) == 0 || std::strcmp( fn, "int __cdecl main(void)" ) == 0? cfn: fn;
}
static char const* adjust_filename( char const* file )
{
#if defined(__INTEL_LLVM_COMPILER) && __INTEL_LLVM_COMPILER >= 20210300
char const* fn = std::strrchr( file, '/' );
return fn? fn + 1: file;
#else
return file;
#endif
}
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, adjust_filename(__FILE__) );
}
{
int const * line = boost::get_error_info<boost::throw_line>( x );
BOOST_TEST( line != 0 );
BOOST_TEST_EQ( *line, 50 );
}
{
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() );
@ -83,23 +29,27 @@ int main()
char const * const * file = boost::get_error_info<boost::throw_file>( x );
BOOST_TEST( file != 0 );
BOOST_TEST_CSTR_EQ( *file, adjust_filename(__FILE__) );
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, 78 );
BOOST_TEST_EQ( *line, 24 );
}
{
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 );
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
}
}
catch( ... )
{
BOOST_ERROR( "BOOST_THROW_EXCEPTION( my_exception2() ) didn't throw boost::exception" );
}
try
{
@ -111,23 +61,27 @@ int main()
char const * const * file = boost::get_error_info<boost::throw_file>( x );
BOOST_TEST( file != 0 );
BOOST_TEST_CSTR_EQ( *file, adjust_filename(__FILE__) );
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, 106 );
BOOST_TEST_EQ( *line, 56 );
}
{
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 );
BOOST_TEST_CSTR_EQ( *function, BOOST_CURRENT_FUNCTION );
}
}
catch( ... )
{
BOOST_ERROR( "BOOST_THROW_EXCEPTION( my_exception3() ) didn't throw boost::exception" );
}
return boost::report_errors();
}

View File

@ -0,0 +1,53 @@
// Copyright 2018, 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>
class my_exception: public std::exception
{
};
class my_exception2: public std::exception, public virtual boost::exception
{
};
int main()
{
try
{
BOOST_THROW_EXCEPTION( my_exception() );
}
catch( std::exception const & x )
{
boost::source_location loc = boost::get_throw_location( x );
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST_EQ( loc.line(), 20 );
BOOST_TEST_CSTR_EQ( loc.function_name(), BOOST_CURRENT_FUNCTION );
}
catch( ... )
{
BOOST_ERROR( "'BOOST_THROW_EXCEPTION( my_exception() )' didn't throw 'std::exception'" );
}
try
{
BOOST_THROW_EXCEPTION( my_exception2() );
}
catch( boost::exception const & x )
{
boost::source_location loc = boost::get_throw_location( x );
BOOST_TEST_CSTR_EQ( loc.file_name(), __FILE__ );
BOOST_TEST_EQ( loc.line(), 37 );
BOOST_TEST_CSTR_EQ( loc.function_name(), BOOST_CURRENT_FUNCTION );
}
catch( ... )
{
BOOST_ERROR( "'BOOST_THROW_EXCEPTION( my_exception2() )' didn't throw 'boost::exception'" );
}
return boost::report_errors();
}

View File

@ -21,6 +21,7 @@
#include "lib2_throw.hpp"
#include "lib3_throw.hpp"
#include "lib4_throw.hpp"
#include "lib5_throw.hpp"
#include <boost/exception/exception.hpp>
#include <boost/exception_ptr.hpp>
#include <boost/exception/get_error_info.hpp>
@ -32,12 +33,13 @@ void test_catch_by_type()
BOOST_TEST_THROWS( lib2::f(), lib2::exception );
BOOST_TEST_THROWS( lib3::f(), lib3::exception );
BOOST_TEST_THROWS( lib4::f(), lib4::exception );
BOOST_TEST_THROWS( lib5::f(), lib5::exception );
}
void test_catch_by_exception()
{
BOOST_TEST_THROWS( lib2::f(), boost::exception );
BOOST_TEST_THROWS( lib3::f(), boost::exception );
BOOST_TEST_THROWS( lib4::f(), boost::exception );
BOOST_TEST_THROWS( lib5::f(), boost::exception );
}
void test_exception_ptr()
@ -51,7 +53,6 @@ void test_exception_ptr()
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
@ -63,6 +64,29 @@ void test_exception_ptr()
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib3::exception );
}
try
{
lib4::f();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib4::exception );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
}
try
{
lib5::f();
}
catch( ... )
{
boost::exception_ptr p = boost::current_exception();
BOOST_TEST_THROWS( boost::rethrow_exception( p ), lib5::exception );
BOOST_TEST_THROWS( boost::rethrow_exception( p ), boost::exception );
}
}
@ -71,7 +95,7 @@ void test_throw_line()
{
try
{
lib3::f();
lib5::f();
}
catch( boost::exception const & x )
{
@ -80,25 +104,6 @@ void test_throw_line()
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()

View File

@ -1,30 +0,0 @@
// 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

View File

@ -1,22 +0,0 @@
// 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();
}

View File

@ -1,64 +0,0 @@
// 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();
}

View File

@ -1,33 +0,0 @@
// 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();
}

View File

@ -1,41 +0,0 @@
// 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();
}