mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 16:28:05 +01:00
Compare commits
95 Commits
feature/re
...
boost-1.77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b41139b28e | ||
|
|
39a19f3c90 | ||
|
|
b4dd5e98c9 | ||
|
|
41e3a7c8af | ||
|
|
aee97e91ce | ||
|
|
98533dedb3 | ||
|
|
fe811d1dd1 | ||
|
|
137ecb4abf | ||
|
|
e5cd7bf852 | ||
|
|
96cd1c0163 | ||
|
|
a9da17f2e2 | ||
|
|
f26dfd3dd7 | ||
|
|
d09c998eb2 | ||
|
|
2374e85dc7 | ||
|
|
9167bf8ee8 | ||
|
|
7f7a9da4d5 | ||
|
|
67ae4d3c47 | ||
|
|
ee028e2f9d | ||
|
|
7657188802 | ||
|
|
210c54b09a | ||
|
|
87bb5616a8 | ||
|
|
6de562c79d | ||
|
|
8efb96350f | ||
|
|
88a7be42b5 | ||
|
|
a3225e78e2 | ||
|
|
3c469fe710 | ||
|
|
c2d044f34e | ||
|
|
9fdfa6c645 | ||
|
|
42a257e17c | ||
|
|
26d0d32c54 | ||
|
|
70b5449e99 | ||
|
|
8043ce0278 | ||
|
|
83a2933afa | ||
|
|
2e707ca921 | ||
|
|
a6c4b6329c | ||
|
|
5b1909eba4 | ||
|
|
9dc13fd82a | ||
|
|
e9cdb10409 | ||
|
|
e625bd0eea | ||
|
|
66656f7044 | ||
|
|
0d8511f571 | ||
|
|
fbc49bbaa0 | ||
|
|
344eb1e1f8 | ||
|
|
20b8e90dff | ||
|
|
a0136e570d | ||
|
|
6586fcb01e | ||
|
|
b74b1e3c8c | ||
|
|
1caaacff57 | ||
|
|
75d5287558 | ||
|
|
25eaf0fdae | ||
|
|
f43293f451 | ||
|
|
f8ab3df822 | ||
|
|
f6fb85d7d3 | ||
|
|
9cd9d8732f | ||
|
|
1b7fd6854d | ||
|
|
610d5f3f78 | ||
|
|
88f7c2bf53 | ||
|
|
723daf5d57 | ||
|
|
3d4c31c213 | ||
|
|
c069ae048f | ||
|
|
28e1b919ac | ||
|
|
b20191f8d7 | ||
|
|
d019c1cdae | ||
|
|
ff77d4c094 | ||
|
|
a21a3050a5 | ||
|
|
08d62ac444 | ||
|
|
45e9dfeba9 | ||
|
|
7d9eb384c6 | ||
|
|
04bfb05b19 | ||
|
|
a650f5d676 | ||
|
|
6ab5fd9dac | ||
|
|
ed14d74323 | ||
|
|
ff9bca96e3 | ||
|
|
8560290b71 | ||
|
|
8b41ff22a6 | ||
|
|
79f9a297cd | ||
|
|
344ea58a77 | ||
|
|
5eae4824ab | ||
|
|
f502e6cda4 | ||
|
|
69bc20fb15 | ||
|
|
fbf7f4a417 | ||
|
|
689e09e86f | ||
|
|
b92035d4d2 | ||
|
|
63a32cea9a | ||
|
|
3e2cb8975f | ||
|
|
4e7c88779b | ||
|
|
3ee8200e75 | ||
|
|
516484a821 | ||
|
|
39bd8ba98f | ||
|
|
f1c0a52426 | ||
|
|
8962c9101a | ||
|
|
329e72fb92 | ||
|
|
6758690d2f | ||
|
|
8f32183b63 | ||
|
|
99db03ee96 |
217
.github/workflows/ci.yml
vendored
Normal file
217
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
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.7
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.7
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-4.9
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: g++-4.9
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.04
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.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-18.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install: g++-11
|
||||
- toolset: clang
|
||||
compiler: clang++-3.5
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.5
|
||||
- toolset: clang
|
||||
compiler: clang++-3.6
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.6
|
||||
- toolset: clang
|
||||
compiler: clang++-3.7
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.7
|
||||
- toolset: clang
|
||||
compiler: clang++-3.8
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.8
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-16.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-16.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"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- 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.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2016
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- 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
|
||||
327
.travis.yml
327
.travis.yml
@@ -4,8 +4,6 @@
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
dist: xenial
|
||||
|
||||
branches:
|
||||
@@ -26,7 +24,26 @@ matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-multilib
|
||||
|
||||
- os: linux
|
||||
arch: arm64
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
|
||||
|
||||
- os: linux
|
||||
arch: ppc64le
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
|
||||
|
||||
- os: linux
|
||||
arch: s390x
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
@@ -49,108 +66,20 @@ matrix:
|
||||
- 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
|
||||
dist: trusty
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
|
||||
compiler: g++-11
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-11 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-10
|
||||
- g++-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
@@ -171,189 +100,75 @@ matrix:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
compiler: clang++-12
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- clang-12
|
||||
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
|
||||
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
|
||||
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
|
||||
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-xenial-7
|
||||
|
||||
- os: linux
|
||||
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-xenial-8
|
||||
|
||||
- os: linux
|
||||
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/xenial/ llvm-toolchain-xenial-9 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
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/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang++-10
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- 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: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
|
||||
- os: freebsd
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
|
||||
osx_image: xcode7.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
|
||||
osx_image: xcode8.3
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
|
||||
osx_image: xcode9.4
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
osx_image: xcode10.1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode11.3
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode12.2
|
||||
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 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||
- ctest --output-on-failure -R boost_system
|
||||
- cmake -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||
- cmake --build . --target tests
|
||||
- ctest --output-on-failure --no-tests=error
|
||||
|
||||
- os: linux
|
||||
env: CMAKE=1 BUILD_SHARED_LIBS=ON
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||
- ctest --output-on-failure -R boost_system
|
||||
- cmake -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
|
||||
- cmake --build . --target tests
|
||||
- ctest --output-on-failure --no-tests=error
|
||||
|
||||
- os: linux
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
@@ -375,7 +190,7 @@ matrix:
|
||||
script:
|
||||
- pip install --user cmake
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="system;core" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake -DBOOST_INCLUDE_LIBRARIES=system -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
- cmake --build . --target install
|
||||
- cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
@@ -396,7 +211,7 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/system/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}
|
||||
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
||||
@@ -16,6 +16,7 @@ environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
@@ -29,8 +30,12 @@ environment:
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
@@ -66,4 +71,4 @@ test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
- b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
|
||||
@@ -10,7 +10,7 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
# Boost.System: Extensible Error Reporting
|
||||
Beman Dawes, Christopher Kohlhoff, Peter Dimov
|
||||
:toc: left
|
||||
:toclevels: 3
|
||||
:toclevels: 4
|
||||
:idprefix:
|
||||
:docinfo: private-footer
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2018 Peter Dimov
|
||||
Copyright 2018-2021 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@@ -11,6 +11,49 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.77
|
||||
|
||||
* The conversion operator from `error_category` to `std::error_category`
|
||||
has been improved and no longer requires `<map>` or `<mutex>`.
|
||||
* The comparison operators of `error_category` are now inline friends
|
||||
instead of member functions (a side effect of the previous change.)
|
||||
* `error_condition` now defers calling `generic_category()` to avoid
|
||||
instantiating the object until it's actually needed.
|
||||
* `error_condition::failed` and `error_condition::message` have been
|
||||
undeprecated, and `operator bool()` now once again returns `failed()`.
|
||||
* The system category now doesn't call `generic_category()`, to avoid
|
||||
instantiating the object.
|
||||
* The return value of `default_error_condition` changes in some cases into
|
||||
an `error_condition` from the generic category, instead of from the system
|
||||
category. This happens on POSIX when the input `error_code` is from
|
||||
the system category and does not correspond to any `errc_t` value.
|
||||
* The interoperability of `error_code` and `std::error_code` has been
|
||||
improved substantially. It is now possible to construct
|
||||
`boost::system::error_code` from `std::error_code`, and it's possible
|
||||
to pass `boost::system::error_code` to functions taking `std::error_code&`.
|
||||
* A stream insertion operator for `error_condition` has been added.
|
||||
|
||||
## Changes in Boost 1.76
|
||||
|
||||
* `windows_error.hpp` is no longer deprecated.
|
||||
|
||||
## Changes in Boost 1.75
|
||||
|
||||
* The platform-specific headers `windows_error.hpp`, `linux_error.hpp`,
|
||||
and `cygwin_error.hpp` emit deprecation messages and are slated for
|
||||
removal.
|
||||
* The old names for `generic_category()` and `system_category()` emit
|
||||
deprecation messages and are slated for removal.
|
||||
* `error_condition::failed` is deprecated and is slated for removal.
|
||||
`operator bool()` for `error_condition` has been reverted to its old
|
||||
meaning of `value() != 0`. This is done for compatibility with
|
||||
`std::error_condition` as the next release is expected to improve
|
||||
interoperability with `<system_error>` even further. _Note that this
|
||||
does not affect_ `error_code::failed`, which is still alive and well.
|
||||
* The overload of `error_condition::message` that takes a buffer is
|
||||
deprecated and is slated for removal, for the same reasons. _Note that
|
||||
this does not affect_ `error_code::message`.
|
||||
|
||||
## Changes in Boost 1.74
|
||||
|
||||
* `operator bool()` now returns `failed()` instead of `value() != 0`.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2018 Peter Dimov
|
||||
Copyright 2018-2021 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@@ -14,6 +14,6 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
This documentation is
|
||||
|
||||
* Copyright 2003-2017 Beman Dawes
|
||||
* Copyright 2018 Peter Dimov
|
||||
* Copyright 2018-2021 Peter Dimov
|
||||
|
||||
and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
////
|
||||
Copyright 2003-2017 Beman Dawes
|
||||
Copyright 2018 Peter Dimov
|
||||
Copyright 2018-2021 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@@ -48,31 +48,53 @@ the old names, but will provide them when the macro `BOOST_SYSTEM_ENABLE_DEPRECA
|
||||
|`native_ecat`|`system_category()`
|
||||
|===
|
||||
|
||||
## <boost/system/error_code.hpp>
|
||||
## <boost/system/{zwsp}is_error_code_enum.hpp>
|
||||
|
||||
### Synopsis
|
||||
### is_error_code_enum
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
class error_category;
|
||||
|
||||
constexpr const error_category & system_category() noexcept;
|
||||
constexpr const error_category & generic_category() noexcept;
|
||||
|
||||
class error_code;
|
||||
class error_condition;
|
||||
|
||||
// "Concept" helpers
|
||||
|
||||
template<class T>
|
||||
struct is_error_code_enum { static const bool value = false; };
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
Users may specialize `is_error_code_enum` for their error enumeration
|
||||
types to indicate that they should be eligible for automatic conversions
|
||||
to `error_code`. This conversion calls `make_error_code(e)`, which should
|
||||
be provided in the same namespace as the enumeration type.
|
||||
|
||||
## <boost/system/{zwsp}is_error_condition_enum.hpp>
|
||||
|
||||
### is_error_condition_enum
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
template<class T>
|
||||
struct is_error_condition_enum { static const bool value = false; };
|
||||
|
||||
// generic error conditions
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
Users may specialize `is_error_condition_enum` for their error enumeration
|
||||
types to indicate that they should be eligible for automatic conversions
|
||||
to `error_condition`. This conversion calls `make_error_condition(e)`, which
|
||||
should be provided in the same namespace as the enumeration type.
|
||||
|
||||
## <boost/system/{zwsp}errc.hpp>
|
||||
|
||||
### errc
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
namespace errc {
|
||||
enum errc_t
|
||||
@@ -163,52 +185,80 @@ namespace boost {
|
||||
template<> struct is_error_condition_enum<errc::errc_t>
|
||||
{ static const bool value = true; };
|
||||
|
||||
// non-member functions
|
||||
|
||||
constexpr bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
constexpr bool operator==( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
constexpr bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
constexpr bool operator!=( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
constexpr bool operator<( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
constexpr bool operator<( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
constexpr error_code make_error_code( errc::errc_t e ) noexcept;
|
||||
constexpr error_condition make_error_condition( errc::errc_t e ) noexcept;
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
The value of each `errc_t` constant is the same as the value of the `<cerrno>`
|
||||
macro shown in the above synopsis.
|
||||
The predefined enumeration type `errc::errc_t` provides named constants
|
||||
corresponding to the values of the `<cerrno>` macros.
|
||||
|
||||
Users may specialize `is_error_code_enum` and `is_error_condition_enum`
|
||||
templates to indicate that a type is eligible for class `error_code` and
|
||||
`error_condition` automatic conversions respectively.
|
||||
```
|
||||
constexpr error_condition make_error_condition( errc::errc_t e ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `error_condition( e, generic_category() )`.
|
||||
|
||||
### Class error_category
|
||||
Since `errc::errc_t` provides a specialization of `is_error_condition_enum`
|
||||
and an overload of `make_error_condition`, it can be converted implicitly to
|
||||
an `error_condition`. This is typically useful when comparing `error_code`
|
||||
values returned from APIs to a portable condition, as in the below example:
|
||||
* {blank}
|
||||
+
|
||||
```
|
||||
void api_function( boost::system::error_code& ec );
|
||||
|
||||
void my_function()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
api_function( ec );
|
||||
|
||||
if( ec == boost::system::errc::no_such_file_or_directory )
|
||||
{
|
||||
// an entity wasn't found (ENOENT)
|
||||
// handle this condition
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
constexpr error_code make_error_code( errc::errc_t e ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `error_code( e, generic_category() )`.
|
||||
|
||||
In addition to `make_error_condition`, `errc::errc_t` provides an overload of
|
||||
`make_error_code`. This allows the creation of generic error codes, an
|
||||
operation typically useful when a function needs to signal a generic failure
|
||||
that does not come from an underlying API, such as for instance an out of
|
||||
memory condition:
|
||||
* {blank}
|
||||
+
|
||||
```
|
||||
void my_api_function( boost::system::error_code& ec )
|
||||
{
|
||||
void* p = std::malloc( 16 );
|
||||
|
||||
if( p == 0 )
|
||||
{
|
||||
// return ENOMEM
|
||||
ec = make_error_code( boost::system::errc::out_of_memory );
|
||||
return;
|
||||
}
|
||||
|
||||
// use p
|
||||
}
|
||||
```
|
||||
|
||||
## <boost/system/{zwsp}error_category.hpp>
|
||||
|
||||
### error_category
|
||||
|
||||
The class `error_category` defines the base class for types used
|
||||
to identify the source and encoding of a particular category of error code.
|
||||
@@ -251,9 +301,13 @@ namespace boost {
|
||||
|
||||
virtual bool failed( int ev ) const noexcept;
|
||||
|
||||
constexpr bool operator==( const error_category & rhs ) const noexcept;
|
||||
constexpr bool operator!=( const error_category & rhs ) const noexcept;
|
||||
constexpr bool operator< ( const error_category & rhs ) const noexcept;
|
||||
friend constexpr bool operator==( const error_category & lhs,
|
||||
const error_category & rhs ) noexcept;
|
||||
friend constexpr bool operator!=( const error_category & lhs,
|
||||
const error_category & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator< ( const error_category & lhs,
|
||||
const error_category & rhs ) noexcept;
|
||||
|
||||
operator std::error_category const & () const;
|
||||
|
||||
@@ -397,37 +451,42 @@ Returns: ::
|
||||
Remarks: ::
|
||||
All calls to this function with the same `ev` must return the same value.
|
||||
|
||||
#### Nonvirtuals
|
||||
#### Comparisons
|
||||
|
||||
```
|
||||
constexpr bool operator==( const error_category & rhs ) const noexcept;
|
||||
friend constexpr bool operator==( const error_category & lhs,
|
||||
const error_category & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `rhs.id_ == 0? this == &rhs: id_ == rhs.id_`.
|
||||
Remarks: :: Two category objects are considered equivalent when they have matching
|
||||
nonzero identifiers, or are the same object.
|
||||
Returns: :: `rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_`.
|
||||
Remarks: :: Two category objects are considered equivalent when they have
|
||||
matching nonzero identifiers, or are the same object.
|
||||
|
||||
```
|
||||
constexpr bool operator!=( const error_category & rhs ) const noexcept;
|
||||
friend constexpr bool operator!=( const error_category & lhs,
|
||||
const error_category & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( *this == rhs )`.
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
constexpr bool operator< ( const error_category & rhs ) const noexcept;
|
||||
constexpr bool operator< ( const error_category & lhs,
|
||||
const error_category & rhs ) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
** If `id_ < rhs.id_`, `true`;
|
||||
** Otherwise, if `id_ > rhs.id_`, `false`;
|
||||
** If `lhs.id_ < rhs.id_`, `true`;
|
||||
** Otherwise, if `lhs.id_ > rhs.id_`, `false`;
|
||||
** Otherwise, if `rhs.id_ != 0`, `false`;
|
||||
** Otherwise, `std::less<error_category const *>()( this, &rhs )`.
|
||||
** Otherwise, `std::less<error_category const *>()( &lhs, &rhs )`.
|
||||
|
||||
#### Conversions
|
||||
|
||||
```
|
||||
operator std::error_category const & () const;
|
||||
@@ -438,7 +497,19 @@ operator std::error_category const & () const;
|
||||
Returns: :: A reference to an `std::error_category` object corresponding
|
||||
to `*this`.
|
||||
|
||||
### Predefined Categories
|
||||
## <boost/system/{zwsp}system_category.hpp>
|
||||
|
||||
### system_category
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
constexpr const error_category & system_category() noexcept;
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
```
|
||||
constexpr const error_category & system_category() noexcept;
|
||||
@@ -446,8 +517,22 @@ constexpr const error_category & system_category() noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: A reference to an `error_category` object identifying errors
|
||||
originating from the operating system.
|
||||
Returns: :: A reference to a predefined `error_category` object identifying
|
||||
errors originating from the operating system.
|
||||
|
||||
## <boost/system/{zwsp}generic_category.hpp>
|
||||
|
||||
### generic_category
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
constexpr const error_category & generic_category() noexcept;
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
```
|
||||
constexpr const error_category & generic_category() noexcept;
|
||||
@@ -455,10 +540,12 @@ constexpr const error_category & generic_category() noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: A reference to an `error_category` object identifying portable
|
||||
error conditions.
|
||||
Returns: :: A reference to a predefined `error_category` object identifying
|
||||
portable error codes and conditions.
|
||||
|
||||
### Class error_code
|
||||
## <boost/system/{zwsp}error_code.hpp>
|
||||
|
||||
### error_code
|
||||
|
||||
The class `error_code` describes an object used to hold error code
|
||||
values, such as those originating from the operating system or other
|
||||
@@ -480,6 +567,8 @@ namespace boost {
|
||||
template <class ErrorCodeEnum>
|
||||
constexpr error_code( ErrorCodeEnum e ) noexcept;
|
||||
|
||||
error_code( std::error_code const& ec ) noexcept;
|
||||
|
||||
// modifiers:
|
||||
|
||||
constexpr void assign( int val, const error_category & cat ) noexcept;
|
||||
@@ -502,14 +591,64 @@ namespace boost {
|
||||
constexpr bool failed() const noexcept;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
|
||||
// comparisons:
|
||||
|
||||
friend constexpr bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator<( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
friend bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
friend bool operator==( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
friend bool operator==( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
friend bool operator!=( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
template<class E>
|
||||
friend constexpr bool operator==( const error_code & lhs, E rhs ) noexcept;
|
||||
template<class E>
|
||||
friend constexpr bool operator==( E lhs, const error_code & rhs ) noexcept;
|
||||
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( const error_code & lhs, E rhs ) noexcept;
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( E lhs, const error_code & rhs ) noexcept;
|
||||
|
||||
// conversions:
|
||||
|
||||
operator std::error_code() const;
|
||||
operator std::error_code();
|
||||
template<class T> operator T& (); // only when T=std::error_code
|
||||
|
||||
private: // exposition only
|
||||
|
||||
int val_;
|
||||
const error_category * cat_;
|
||||
// stream insertion:
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
};
|
||||
|
||||
// non-member functions
|
||||
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -522,7 +661,7 @@ constexpr error_code() noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == 0`; `*cat_ == system_category()`.
|
||||
Ensures: :: `value() == 0`; `category() == system_category()`.
|
||||
|
||||
```
|
||||
constexpr error_code( int val, const error_category & cat ) noexcept;
|
||||
@@ -530,7 +669,7 @@ constexpr error_code( int val, const error_category & cat ) noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == val`; `cat_ == &cat`.
|
||||
Ensures: :: `value() == val`; `category() == cat`.
|
||||
|
||||
```
|
||||
template <class ErrorCodeEnum>
|
||||
@@ -542,6 +681,15 @@ template <class ErrorCodeEnum>
|
||||
Ensures: :: `*this == make_error_code( e )`.
|
||||
Remarks: :: This constructor is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`.
|
||||
|
||||
```
|
||||
error_code( std::error_code const & ec ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: Construct an `error_code` that wraps `ec`.
|
||||
Remarks: :: `value()` and `category()` are unspecified.
|
||||
|
||||
#### Modifiers
|
||||
|
||||
```
|
||||
@@ -550,7 +698,7 @@ constexpr void assign( int val, const error_category & cat ) noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == val`; `cat_ == &cat`.
|
||||
Ensures: :: `value() == val`; `category() == cat`.
|
||||
|
||||
```
|
||||
template<typename ErrorCodeEnum>
|
||||
@@ -569,7 +717,7 @@ constexpr void clear() noexcept;
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`val_ == 0`; `*cat_ == system_category()`.
|
||||
`value() == 0`; `category() == system_category()`.
|
||||
|
||||
#### Observers
|
||||
|
||||
@@ -579,7 +727,7 @@ constexpr int value() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `val_`.
|
||||
Returns: :: the error value.
|
||||
|
||||
```
|
||||
constexpr const error_category & category() const noexcept;
|
||||
@@ -587,7 +735,7 @@ constexpr const error_category & category() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `*cat_`.
|
||||
Returns: :: the error category.
|
||||
|
||||
```
|
||||
error_condition default_error_condition() const noexcept;
|
||||
@@ -595,7 +743,7 @@ error_condition default_error_condition() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->default_error_condition( val_ )`.
|
||||
Returns: :: `category().default_error_condition( value() )`.
|
||||
|
||||
```
|
||||
std::string message() const;
|
||||
@@ -603,7 +751,8 @@ std::string message() const;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_ )`.
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec.message()`.
|
||||
Otherwise, `category().message( value() )`.
|
||||
|
||||
```
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
@@ -611,7 +760,9 @@ char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_, buffer, len )`.
|
||||
Effects: :: If `*this` wraps a `std::error_code` object `ec`, copies the
|
||||
string returned from `ec.message()` into `buffer` and returns `buffer`.
|
||||
Otherwise, returns `category().message( value(), buffer, len )`.
|
||||
|
||||
```
|
||||
constexpr bool failed() const noexcept;
|
||||
@@ -619,7 +770,8 @@ constexpr bool failed() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->failed( val_ )`.
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec.value() != 0`.
|
||||
Otherwise, `category().failed( value() )`.
|
||||
|
||||
```
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
@@ -627,18 +779,197 @@ constexpr explicit operator bool() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `failed()`.
|
||||
Returns: ::
|
||||
`failed()`.
|
||||
|
||||
#### Comparisons
|
||||
|
||||
```
|
||||
operator std::error_code() const;
|
||||
friend constexpr bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If both `lhs` and `rhs` wrap `std::error_code` objects `e1` and `e2`, `e1 == e2`.
|
||||
Otherwise, `lhs.value() == rhs.value() && lhs.category() == rhs.category()`.
|
||||
|
||||
```
|
||||
friend constexpr bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
friend constexpr bool operator<( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If both `lhs` and `rhs` wrap `std::error_code` objects `e1` and `e2`, `e1 < e2`.
|
||||
Otherwise, `lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value())`.
|
||||
|
||||
```
|
||||
friend bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If `code` wraps a `std::error_code` object `ec`, `ec == static_cast<std::error_condition>( condition )`.
|
||||
Otherwise, `code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() )`.
|
||||
|
||||
```
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator!=( const error_condition & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
friend bool operator==( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `static_cast<std::error_code>(lhs) == rhs`.
|
||||
|
||||
```
|
||||
friend bool operator==( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `lhs == static_cast<std::error_code>(rhs)`.
|
||||
|
||||
```
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator!=( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`std::error_code( val_, *cat_ )`.
|
||||
`!( lhs == rhs )`.
|
||||
|
||||
### Class error_condition
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator==( const error_code & lhs, E rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
[disc]
|
||||
** When `is_error_code_enum<E>::value` is `true`, returns `lhs == make_error_code(rhs)`;
|
||||
** When `is_error_condition_enum<E>::value` is `true`, returns `lhs == make_error_condition(rhs)`;
|
||||
** Otherwise, this overload is disabled.
|
||||
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator==( E lhs, const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
[disc]
|
||||
** When `is_error_code_enum<E>::value` is `true`, returns `make_error_code(lhs) == rhs`;
|
||||
** When `is_error_condition_enum<E>::value` is `true`, returns `make_error_condition(lhs) == rhs`;
|
||||
** Otherwise, this overload is disabled.
|
||||
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( const error_code & lhs, E rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( E lhs, const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
Remarks: :: These overloads are only enabled when
|
||||
`is_error_code_enum<E>::value` is `true` or
|
||||
`is_error_condition_enum<E>::value` is `true`.
|
||||
|
||||
#### Conversions
|
||||
|
||||
```
|
||||
operator std::error_code() const;
|
||||
```
|
||||
```
|
||||
operator std::error_code();
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec`.
|
||||
Otherwise, `std::error_code( value(), category() )`.
|
||||
|
||||
```
|
||||
template<class T> operator T&();
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: If `*this` wraps a `std::error_code` object `ec`,
|
||||
returns a reference to `ec`.
|
||||
Otherwise, makes `*this` wrap `std::error_code( *this )`,
|
||||
then returns a reference to it.
|
||||
Remarks: ::
|
||||
This operator is only enabled when `T` is `std::error_code`.
|
||||
|
||||
#### Stream Insertion
|
||||
|
||||
```
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: If `ec` wraps a `std::error_code` object `e2`, `os << "std:" << e2`.
|
||||
Otherwise, `os << ec.category().name() << ':' << ec.value()`.
|
||||
Returns: ::
|
||||
`os`.
|
||||
|
||||
#### Nonmembers
|
||||
|
||||
```
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If `ec` wraps a `std::error_code` object `e2`, `std::hash<std::error_code>()(e2)`.
|
||||
Otherwise, a hash value representing `ec`.
|
||||
|
||||
## <boost/system/{zwsp}error_condition.hpp>
|
||||
|
||||
### error_condition
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
@@ -675,13 +1006,36 @@ namespace boost {
|
||||
constexpr bool failed() const noexcept;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
|
||||
// comparisons:
|
||||
|
||||
friend constexpr bool operator==( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator!=( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator<( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend bool operator==( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
|
||||
friend bool operator!=( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator!=( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
|
||||
// conversions:
|
||||
|
||||
operator std::error_condition() const;
|
||||
|
||||
private: // exposition only
|
||||
|
||||
int val_;
|
||||
const error_category * cat_;
|
||||
// stream insertion:
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_condition & en );
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -695,7 +1049,7 @@ constexpr error_condition() noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == 0`; `*cat_ == generic_category()`.
|
||||
Ensures: :: `value() == 0`; `category() == generic_category()`.
|
||||
|
||||
```
|
||||
constexpr error_condition( int val, const error_category & cat ) noexcept;
|
||||
@@ -703,7 +1057,7 @@ constexpr error_condition( int val, const error_category & cat ) noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == val`; `cat_ == &cat`.
|
||||
Ensures: :: `value() == val`; `category() == cat`.
|
||||
|
||||
```
|
||||
template <class ErrorConditionEnum>
|
||||
@@ -724,7 +1078,7 @@ constexpr void assign( int val, const error_category & cat ) noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: :: `val_ == val`; `cat_ == &cat`.
|
||||
Ensures: :: `value() == val`; `category() == cat`.
|
||||
|
||||
```
|
||||
template <class ErrorConditionEnum>
|
||||
@@ -743,7 +1097,7 @@ constexpr void clear() noexcept;
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`val_ == 0`; `*cat_ == generic_category()`.
|
||||
`value() == 0`; `category() == generic_category()`.
|
||||
|
||||
#### Observers
|
||||
|
||||
@@ -753,7 +1107,7 @@ constexpr int value() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `val_`.
|
||||
Returns: :: the error value.
|
||||
|
||||
```
|
||||
constexpr const error_category & category() const noexcept;
|
||||
@@ -761,7 +1115,7 @@ constexpr const error_category & category() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `*cat_`.
|
||||
Returns: :: the error category.
|
||||
|
||||
```
|
||||
std::string message() const;
|
||||
@@ -769,7 +1123,7 @@ std::string message() const;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_ )`.
|
||||
Returns: :: `category().message( value() )`.
|
||||
|
||||
```
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
@@ -777,7 +1131,7 @@ char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_, buffer, len )`.
|
||||
Returns: :: `category().message( value(), buffer, len )`.
|
||||
|
||||
```
|
||||
constexpr bool failed() const noexcept;
|
||||
@@ -785,7 +1139,7 @@ constexpr bool failed() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->failed( val_ )`.
|
||||
Returns: :: `category().failed( value() )`.
|
||||
|
||||
```
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
@@ -793,23 +1147,13 @@ constexpr explicit operator bool() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `failed()`.
|
||||
|
||||
```
|
||||
operator std::error_condition() const;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`std::error_condition( val_, *cat_ )`.
|
||||
`failed()`.
|
||||
|
||||
### Nonmember functions
|
||||
#### Comparisons
|
||||
|
||||
```
|
||||
constexpr bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
constexpr bool operator==( const error_condition & lhs,
|
||||
friend constexpr bool operator==( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
@@ -818,25 +1162,8 @@ constexpr bool operator==( const error_condition & lhs,
|
||||
Returns: :: `lhs.value() == rhs.value() && lhs.category() == rhs.category()`.
|
||||
|
||||
```
|
||||
bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() )`.
|
||||
|
||||
```
|
||||
constexpr bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
constexpr bool operator!=( const error_condition & lhs,
|
||||
friend constexpr bool operator!=( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
@@ -844,53 +1171,68 @@ bool operator!=( const error_condition & condition,
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
constexpr bool operator<( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
constexpr bool operator<( const error_condition & lhs,
|
||||
friend constexpr bool operator<( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `lhs.category() < rhs.category() || ( lhs.category() == rhs.category() && lhs.value() < rhs.value() )`.
|
||||
Returns: ::
|
||||
`lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value())`.
|
||||
|
||||
```
|
||||
constexpr error_code make_error_code( errc::errc_t e ) noexcept;
|
||||
friend bool operator==( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `error_code( e, generic_category() )`.
|
||||
Returns: :: `code == static_cast<std::error_condition>( rhs )`.
|
||||
|
||||
```
|
||||
constexpr error_condition make_error_condition( errc::errc_t e ) noexcept;
|
||||
friend constexpr bool operator!=( const std::error_code & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `error_condition( e, generic_category() )`.
|
||||
|
||||
```
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: `os << ec.category().name() << ':' << ec.value()`.
|
||||
Returns: :: `os`.
|
||||
|
||||
```
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
friend constexpr bool operator!=( const error_condition & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
A hash value representing `ec`.
|
||||
`!( lhs == rhs )`.
|
||||
|
||||
## <boost/system/system_error.hpp>
|
||||
#### Conversions
|
||||
|
||||
```
|
||||
operator std::error_condition() const;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`std::error_condition( value(), category() )`.
|
||||
|
||||
#### Stream Insertion
|
||||
|
||||
```
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_condition & en );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: `os << "cond:" << en.category().name() << ':' << en.value()`.
|
||||
Returns: ::
|
||||
`os`.
|
||||
|
||||
## <boost/system/{zwsp}system_error.hpp>
|
||||
|
||||
### Class system_error
|
||||
|
||||
@@ -967,4 +1309,8 @@ const char * what() const noexcept;
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: A null-terminated character string incorporating the arguments supplied
|
||||
in the constructor, typically of the form `what_arg + ": " + code.message()`.
|
||||
in the constructor, typically of the form `what_arg + ": " + code().message()`.
|
||||
|
||||
## <boost/system.hpp>
|
||||
|
||||
This convenience header includes all the headers previously described.
|
||||
|
||||
13
include/boost/system.hpp
Normal file
13
include/boost/system.hpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef BOOST_SYSTEM_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_HPP_INCLUDED
|
||||
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_HPP_INCLUDED
|
||||
@@ -10,6 +10,13 @@
|
||||
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||
#endif
|
||||
|
||||
// This header is effectively empty for compiles on operating systems where
|
||||
// it is not applicable.
|
||||
|
||||
|
||||
@@ -13,20 +13,10 @@
|
||||
|
||||
// BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)
|
||||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC)
|
||||
# define BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_GCC, < 40600)
|
||||
// g++ 4.4's <map> is not good enough
|
||||
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_HDR_MUTEX)
|
||||
// Required for thread-safe map manipulation
|
||||
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
#endif
|
||||
|
||||
// BOOST_SYSTEM_NOEXCEPT
|
||||
// Retained for backward compatibility
|
||||
|
||||
@@ -48,4 +38,28 @@
|
||||
# define BOOST_SYSTEM_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// BOOST_SYSTEM_DEPRECATED
|
||||
|
||||
#if defined(__clang__)
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
#elif defined(__GNUC__)
|
||||
# if __GNUC__ * 100 + __GNUC_MINOR__ >= 405
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
# else
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated))
|
||||
# endif
|
||||
#elif defined(_MSC_VER)
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
#elif defined(__sun)
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
#else
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg)
|
||||
#endif
|
||||
|
||||
// BOOST_SYSTEM_CLANG_6
|
||||
|
||||
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11))
|
||||
# define BOOST_SYSTEM_CLANG_6
|
||||
#endif
|
||||
|
||||
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <system_error>
|
||||
# include <atomic>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
@@ -38,11 +39,7 @@ namespace detail
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed_impl( int ev, error_category const & cat );
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
std::error_category const & to_std_category( error_category const & cat );
|
||||
|
||||
#endif
|
||||
class std_category;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -58,10 +55,6 @@ private:
|
||||
friend std::size_t hash_value( error_code const & ec );
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool detail::failed_impl( int ev, error_category const & cat );
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
friend std::error_category const & detail::to_std_category( error_category const & cat );
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
public:
|
||||
|
||||
@@ -80,6 +73,16 @@ private:
|
||||
|
||||
boost::ulong_long_type id_;
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
mutable std::atomic< boost::system::detail::std_category* > ps_;
|
||||
|
||||
#else
|
||||
|
||||
boost::system::detail::std_category* ps_;
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
||||
@@ -97,11 +100,11 @@ protected:
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
|
||||
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 ), ps_()
|
||||
{
|
||||
}
|
||||
|
||||
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
|
||||
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), ps_()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -121,24 +124,24 @@ public:
|
||||
return ev != 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
|
||||
return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( *this == rhs );
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( id_ < rhs.id_ )
|
||||
if( lhs.id_ < rhs.id_ )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if( id_ > rhs.id_ )
|
||||
if( lhs.id_ > rhs.id_ )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -148,13 +151,15 @@ public:
|
||||
return false; // equal
|
||||
}
|
||||
|
||||
return std::less<error_category const *>()( this, &rhs );
|
||||
return std::less<error_category const *>()( &lhs, &rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
# if defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
operator std::error_category const & () const;
|
||||
|
||||
# else
|
||||
operator std::error_category const & () const BOOST_SYMBOL_VISIBLE;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -167,6 +172,7 @@ namespace detail
|
||||
|
||||
static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D;
|
||||
static const boost::ulong_long_type system_category_id = ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B;
|
||||
static const boost::ulong_long_type interop_category_id = ( boost::ulong_long_type( 0x943F2817 ) << 32 ) + 0xFD3A8FAF;
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@@ -83,7 +84,8 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
catch( ... )
|
||||
{
|
||||
return "Message text unavailable";
|
||||
detail::snprintf( buffer, len, "No message text available for error %d", ev );
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -96,11 +98,40 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
#include <boost/system/detail/to_std_category.hpp>
|
||||
#include <boost/system/detail/std_category.hpp>
|
||||
|
||||
inline boost::system::error_category::operator std::error_category const & () const
|
||||
{
|
||||
return boost::system::detail::to_std_category( *this );
|
||||
if( id_ == boost::system::detail::system_category_id )
|
||||
{
|
||||
static const boost::system::detail::std_category system_instance( this, 0x1F4D7 );
|
||||
return system_instance;
|
||||
}
|
||||
|
||||
if( id_ == boost::system::detail::generic_category_id )
|
||||
{
|
||||
static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 );
|
||||
return generic_instance;
|
||||
}
|
||||
|
||||
boost::system::detail::std_category* p = ps_.load( std::memory_order_acquire );
|
||||
|
||||
if( p != 0 )
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
boost::system::detail::std_category* q = new detail::std_category( this, 0 );
|
||||
|
||||
if( ps_.compare_exchange_strong( p, q, std::memory_order_release, std::memory_order_acquire ) )
|
||||
{
|
||||
return *q;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete q;
|
||||
return *p;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
@@ -10,15 +10,29 @@
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/is_error_code_enum.hpp>
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/system_category.hpp>
|
||||
#include <boost/system/detail/system_category_impl.hpp>
|
||||
#include <boost/system/detail/interop_category.hpp>
|
||||
#include <boost/system/detail/enable_if.hpp>
|
||||
#include <boost/system/is_error_code_enum.hpp>
|
||||
#include <boost/system/detail/is_same.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <system_error>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -35,26 +49,50 @@ namespace system
|
||||
// and error_code containing a pointer to an object of a type derived
|
||||
// from error_category.
|
||||
|
||||
std::size_t hash_value( error_code const & ec );
|
||||
|
||||
class error_code
|
||||
{
|
||||
private:
|
||||
|
||||
int val_;
|
||||
bool failed_;
|
||||
const error_category * cat_;
|
||||
friend std::size_t hash_value( error_code const & ec );
|
||||
|
||||
private:
|
||||
|
||||
struct data
|
||||
{
|
||||
int val_;
|
||||
const error_category * cat_;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
data d1_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
unsigned char d2_[ sizeof(std::error_code) ];
|
||||
#endif
|
||||
};
|
||||
|
||||
// 0: default constructed, d1_ value initialized
|
||||
// 1: holds std::error_code in d2_
|
||||
// 2: holds error code in d1_, failed == false
|
||||
// 3: holds error code in d1_, failed == true
|
||||
unsigned flags_;
|
||||
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
|
||||
val_( 0 ), failed_( false ), cat_( &system_category() )
|
||||
d1_(), flags_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||
d1_(), flags_( 2 + detail::failed_impl( val, cat ) )
|
||||
{
|
||||
d1_.val_ = val;
|
||||
d1_.cat_ = &cat;
|
||||
}
|
||||
|
||||
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
||||
@@ -63,13 +101,21 @@ public:
|
||||
*this = make_error_code( e );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
error_code( std::error_code const& ec ) BOOST_NOEXCEPT:
|
||||
flags_( 1 )
|
||||
{
|
||||
::new( d2_ ) std::error_code( ec );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// modifiers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = val;
|
||||
failed_ = detail::failed_impl( val, cat );
|
||||
cat_ = &cat;
|
||||
*this = error_code( val, cat );
|
||||
}
|
||||
|
||||
template<typename ErrorCodeEnum>
|
||||
@@ -82,48 +128,113 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = &system_category();
|
||||
*this = error_code();
|
||||
}
|
||||
|
||||
// observers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||
{
|
||||
return val_;
|
||||
if( flags_ != 1 )
|
||||
{
|
||||
return d1_.val_;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.value() + 1000 * static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
||||
#else
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||
{
|
||||
return *cat_;
|
||||
if( flags_ == 0 )
|
||||
{
|
||||
return system_category();
|
||||
}
|
||||
else if( flags_ == 1 )
|
||||
{
|
||||
return detail::interop_category();
|
||||
}
|
||||
else
|
||||
{
|
||||
return *d1_.cat_;
|
||||
}
|
||||
}
|
||||
|
||||
// deprecated?
|
||||
error_condition default_error_condition() const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->default_error_condition( value() );
|
||||
return category().default_error_condition( value() );
|
||||
}
|
||||
|
||||
std::string message() const
|
||||
{
|
||||
return cat_->message( value() );
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.message();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return category().message( value() );
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->message( value(), buffer, len );
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
try
|
||||
#endif
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
detail::snprintf( buffer, len, "%s", ec.message().c_str() );
|
||||
return buffer;
|
||||
}
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return category().message( value(), buffer, len );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
{
|
||||
return failed_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.value() != 0;
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return (flags_ & 1) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_;
|
||||
return failed();
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -133,12 +244,12 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_? unspecified_bool_true: 0;
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed_;
|
||||
return !failed();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -150,39 +261,266 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.flags_ == 1 && rhs.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
|
||||
return e1 == e2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return lhs.value() == rhs.value() && lhs.category() == rhs.category();
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.flags_ == 1 && rhs.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
|
||||
return e1 < e2;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value());
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
operator std::error_code () const
|
||||
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::error_code( value(), category() );
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( error_code const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator==( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_condition( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_condition( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator!=( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator!=( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_code( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_code( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_CLANG_6)
|
||||
|
||||
inline friend bool operator==( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator==( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// conversions
|
||||
|
||||
operator std::error_code () const
|
||||
{
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
return *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
}
|
||||
else if( flags_ == 0 )
|
||||
{
|
||||
//return std::error_code();
|
||||
return std::error_code( 0, boost::system::system_category() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::error_code( d1_.val_, *d1_.cat_ );
|
||||
}
|
||||
}
|
||||
|
||||
operator std::error_code ()
|
||||
{
|
||||
return const_cast<error_code const&>( *this );
|
||||
}
|
||||
|
||||
template<class T,
|
||||
class E = typename detail::enable_if<detail::is_same<T, std::error_code>::value>::type>
|
||||
operator T& ()
|
||||
{
|
||||
if( flags_ != 1 )
|
||||
{
|
||||
std::error_code e2( *this );
|
||||
::new( d2_ ) std::error_code( e2 );
|
||||
flags_ = 1;
|
||||
}
|
||||
|
||||
return *reinterpret_cast<std::error_code*>( d2_ );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_CLANG_6)
|
||||
|
||||
template<class T,
|
||||
class E = typename std::enable_if<std::is_same<T, std::error_code>::value>::type>
|
||||
operator T const& () = delete;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline friend std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( ec.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( ec.d2_ );
|
||||
os << "std:" << e2.category().name() << ':' << e2.value();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
os << ec.category().name() << ':' << ec.value();
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||
{
|
||||
os << ec.category().name() << ':' << ec.value();
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value( error_code const & ec )
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( ec.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( ec.d2_ );
|
||||
return std::hash<std::error_code>()( e2 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
error_category const & cat = ec.category();
|
||||
|
||||
boost::ulong_long_type id_ = cat.id_;
|
||||
@@ -212,4 +550,8 @@ inline std::size_t hash_value( error_code const & ec )
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/generic_category.hpp>
|
||||
#include <boost/system/detail/enable_if.hpp>
|
||||
#include <boost/system/detail/is_same.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/is_error_condition_enum.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@@ -27,6 +29,17 @@ namespace system
|
||||
|
||||
// error_conditions are portable, error_codes are system or library specific
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct generic_value_tag
|
||||
{
|
||||
int value;
|
||||
BOOST_SYSTEM_CONSTEXPR explicit generic_value_tag( int v ): value( v ) {}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
class error_condition
|
||||
{
|
||||
private:
|
||||
@@ -40,7 +53,7 @@ public:
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||
val_( 0 ), failed_( false ), cat_( &generic_category() )
|
||||
val_( 0 ), failed_( false ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,12 +62,25 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit error_condition( boost::system::detail::generic_value_tag vt ) BOOST_NOEXCEPT:
|
||||
val_( vt.value ), failed_( vt.value != 0 ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
||||
typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type* = 0) BOOST_NOEXCEPT
|
||||
typename detail::enable_if<
|
||||
is_error_condition_enum<ErrorConditionEnum>::value && !boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value
|
||||
>::type* = 0) BOOST_NOEXCEPT
|
||||
{
|
||||
*this = make_error_condition( e );
|
||||
}
|
||||
|
||||
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
||||
typename detail::enable_if<boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value>::type* = 0) BOOST_NOEXCEPT:
|
||||
val_( e ), failed_( e != 0 ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
// modifiers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
@@ -68,7 +94,7 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
|
||||
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
|
||||
{
|
||||
*this = make_error_condition( val );
|
||||
*this = error_condition( val );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -76,7 +102,7 @@ public:
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = &generic_category();
|
||||
cat_ = 0;
|
||||
}
|
||||
|
||||
// observers:
|
||||
@@ -88,17 +114,31 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||
{
|
||||
return *cat_;
|
||||
return cat_? *cat_: generic_category();
|
||||
}
|
||||
|
||||
std::string message() const
|
||||
{
|
||||
return cat_->message( value() );
|
||||
if( cat_ )
|
||||
{
|
||||
return cat_->message( value() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return generic_category().message( value() );
|
||||
}
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->message( value(), buffer, len );
|
||||
if( cat_ )
|
||||
{
|
||||
return cat_->message( value(), buffer, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
return generic_category().message( value(), buffer, len );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
@@ -136,12 +176,19 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
|
||||
return lhs.val_ == rhs.val_ && lhs.category() == rhs.category();
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
|
||||
error_category const& lcat = lhs.category();
|
||||
error_category const& rcat = rhs.category();
|
||||
return lcat < rcat || ( lcat == rcat && lhs.val_ < rhs.val_ );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
@@ -151,13 +198,39 @@ public:
|
||||
return std::error_condition( value(), category() );
|
||||
}
|
||||
|
||||
#endif
|
||||
};
|
||||
inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == static_cast< std::error_condition >( rhs );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
inline friend bool operator==( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_condition >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline friend std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_condition const & en)
|
||||
{
|
||||
{
|
||||
os << "cond:" << en.category().name() << ':' << en.value();
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
|
||||
@@ -109,10 +109,10 @@ inline error_category const & generic_category() BOOST_NOEXCEPT
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
|
||||
inline const error_category & get_generic_category() { return generic_category(); }
|
||||
inline const error_category & get_posix_category() { return generic_category(); }
|
||||
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||
BOOST_SYSTEM_DEPRECATED("please use generic_category()") inline const error_category & get_generic_category() { return generic_category(); }
|
||||
BOOST_SYSTEM_DEPRECATED("please use generic_category()") inline const error_category & get_posix_category() { return generic_category(); }
|
||||
BOOST_SYSTEM_DEPRECATED("please use generic_category()") static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||
BOOST_SYSTEM_DEPRECATED("please use generic_category()") static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
107
include/boost/system/detail/interop_category.hpp
Normal file
107
include/boost/system/detail/interop_category.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED
|
||||
|
||||
// Copyright Beman Dawes 2006, 2007
|
||||
// Copyright Christoper Kohlhoff 2007
|
||||
// Copyright Peter Dimov 2017, 2018, 2021
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// interop_error_category, used for std::error_code
|
||||
|
||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#endif
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE interop_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR interop_error_category() BOOST_NOEXCEPT:
|
||||
error_category( detail::interop_category_id )
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
{
|
||||
return "std:unknown";
|
||||
}
|
||||
|
||||
std::string message( int ev ) const BOOST_OVERRIDE;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
};
|
||||
|
||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
inline char const * interop_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
detail::snprintf( buffer, len, "Unknown interop error %d", ev );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
inline std::string interop_error_category::message( int ev ) const
|
||||
{
|
||||
char buffer[ 48 ];
|
||||
return message( ev, buffer, sizeof( buffer ) );
|
||||
}
|
||||
|
||||
// interop_category()
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
template<class T> struct BOOST_SYMBOL_VISIBLE interop_cat_holder
|
||||
{
|
||||
static constexpr interop_error_category instance{};
|
||||
};
|
||||
|
||||
// Before C++17 it was mandatory to redeclare all static constexpr
|
||||
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
template<class T> constexpr interop_error_category interop_cat_holder<T>::instance;
|
||||
#endif
|
||||
|
||||
constexpr error_category const & interop_category() BOOST_NOEXCEPT
|
||||
{
|
||||
return interop_cat_holder<void>::instance;
|
||||
}
|
||||
|
||||
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
inline error_category const & interop_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
inline error_category const & interop_category() BOOST_NOEXCEPT
|
||||
{
|
||||
static const detail::interop_error_category instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED
|
||||
@@ -1,125 +0,0 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_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)
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
|
||||
{
|
||||
using namespace errc;
|
||||
|
||||
static int const gen[] =
|
||||
{
|
||||
success,
|
||||
address_family_not_supported,
|
||||
address_in_use,
|
||||
address_not_available,
|
||||
already_connected,
|
||||
argument_list_too_long,
|
||||
argument_out_of_domain,
|
||||
bad_address,
|
||||
bad_file_descriptor,
|
||||
bad_message,
|
||||
broken_pipe,
|
||||
connection_aborted,
|
||||
connection_already_in_progress,
|
||||
connection_refused,
|
||||
connection_reset,
|
||||
cross_device_link,
|
||||
destination_address_required,
|
||||
device_or_resource_busy,
|
||||
directory_not_empty,
|
||||
executable_format_error,
|
||||
file_exists,
|
||||
file_too_large,
|
||||
filename_too_long,
|
||||
function_not_supported,
|
||||
host_unreachable,
|
||||
identifier_removed,
|
||||
illegal_byte_sequence,
|
||||
inappropriate_io_control_operation,
|
||||
interrupted,
|
||||
invalid_argument,
|
||||
invalid_seek,
|
||||
io_error,
|
||||
is_a_directory,
|
||||
message_size,
|
||||
network_down,
|
||||
network_reset,
|
||||
network_unreachable,
|
||||
no_buffer_space,
|
||||
no_child_process,
|
||||
no_link,
|
||||
no_lock_available,
|
||||
no_message_available,
|
||||
no_message,
|
||||
no_protocol_option,
|
||||
no_space_on_device,
|
||||
no_stream_resources,
|
||||
no_such_device_or_address,
|
||||
no_such_device,
|
||||
no_such_file_or_directory,
|
||||
no_such_process,
|
||||
not_a_directory,
|
||||
not_a_socket,
|
||||
not_a_stream,
|
||||
not_connected,
|
||||
not_enough_memory,
|
||||
not_supported,
|
||||
operation_canceled,
|
||||
operation_in_progress,
|
||||
operation_not_permitted,
|
||||
operation_not_supported,
|
||||
operation_would_block,
|
||||
owner_dead,
|
||||
permission_denied,
|
||||
protocol_error,
|
||||
protocol_not_supported,
|
||||
read_only_file_system,
|
||||
resource_deadlock_would_occur,
|
||||
resource_unavailable_try_again,
|
||||
result_out_of_range,
|
||||
state_not_recoverable,
|
||||
stream_timeout,
|
||||
text_file_busy,
|
||||
timed_out,
|
||||
too_many_files_open_in_system,
|
||||
too_many_files_open,
|
||||
too_many_links,
|
||||
too_many_symbolic_link_levels,
|
||||
value_too_large,
|
||||
wrong_protocol_type
|
||||
};
|
||||
|
||||
int const n = sizeof( gen ) / sizeof( gen[0] );
|
||||
|
||||
for( int i = 0; i < n; ++i )
|
||||
{
|
||||
if( ev == gen[ i ] ) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
|
||||
33
include/boost/system/detail/is_same.hpp
Normal file
33
include/boost/system/detail/is_same.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T1, class T2> struct is_same
|
||||
{
|
||||
enum _vt { value = 0 };
|
||||
};
|
||||
|
||||
template<class T> struct is_same<T, T>
|
||||
{
|
||||
enum _vt { value = 1 };
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
70
include/boost/system/detail/snprintf.hpp
Normal file
70
include/boost/system/detail/snprintf.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||
|
||||
// Copyright 2018, 2020, 2021 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)
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
||||
|
||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
||||
{
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4996 )
|
||||
# endif
|
||||
|
||||
if( len == 0 ) return;
|
||||
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
|
||||
_vsnprintf( buffer, len - 1, format, args );
|
||||
buffer[ len - 1 ] = 0;
|
||||
|
||||
va_end( args );
|
||||
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
|
||||
std::vsnprintf( buffer, len, format, args );
|
||||
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||
#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
|
||||
|
||||
// Support for interoperability between Boost.System and <system_error>
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
// Copyright 2018, 2021 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)
|
||||
@@ -15,9 +15,6 @@
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/generic_category.hpp>
|
||||
#include <system_error>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
//
|
||||
|
||||
@@ -73,54 +70,6 @@ public:
|
||||
bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
};
|
||||
|
||||
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
struct cat_ptr_less
|
||||
{
|
||||
bool operator()( boost::system::error_category const * p1, boost::system::error_category const * p2 ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return *p1 < *p2;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::error_category const & to_std_category( boost::system::error_category const & cat )
|
||||
{
|
||||
if( cat.id_ == boost::system::detail::system_category_id )
|
||||
{
|
||||
static const std_category system_instance( &cat, 0x1F4D7 );
|
||||
return system_instance;
|
||||
}
|
||||
else if( cat.id_ == boost::system::detail::generic_category_id )
|
||||
{
|
||||
static const std_category generic_instance( &cat, 0x1F4D3 );
|
||||
return generic_instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category>, cat_ptr_less > map_type;
|
||||
|
||||
static map_type map_;
|
||||
static std::mutex map_mx_;
|
||||
|
||||
std::lock_guard<std::mutex> guard( map_mx_ );
|
||||
|
||||
map_type::iterator i = map_.find( &cat );
|
||||
|
||||
if( i == map_.end() )
|
||||
{
|
||||
std::unique_ptr<std_category> p( new std_category( &cat, 0 ) );
|
||||
|
||||
std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );
|
||||
|
||||
i = r.first;
|
||||
}
|
||||
|
||||
return *i->second;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT
|
||||
{
|
||||
if( condition.category() == *this )
|
||||
@@ -170,6 +119,7 @@ inline bool std_category::equivalent( const std::error_code & code, int conditio
|
||||
boost::system::error_code bc( code.value(), *pc2->pc_ );
|
||||
return pc_->equivalent( bc, condition );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
else if( *pc_ == boost::system::generic_category() )
|
||||
@@ -188,4 +138,4 @@ inline bool std_category::equivalent( const std::error_code & code, int conditio
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
|
||||
@@ -98,8 +98,8 @@ inline error_category const & system_category() BOOST_NOEXCEPT
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
|
||||
inline const error_category & get_system_category() { return system_category(); }
|
||||
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
|
||||
BOOST_SYSTEM_DEPRECATED("please use system_category()") inline const error_category & get_system_category() { return system_category(); }
|
||||
BOOST_SYSTEM_DEPRECATED("please use system_category()") static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -97,11 +97,12 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
case ERROR_RETRY_: return resource_unavailable_try_again;
|
||||
case ERROR_SEEK_: return io_error;
|
||||
case ERROR_SHARING_VIOLATION_: return permission_denied;
|
||||
case ERROR_NOT_SUPPORTED_: return not_supported; // WinError.h: "The request is not supported."
|
||||
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
|
||||
case ERROR_WRITE_FAULT_: return io_error;
|
||||
case ERROR_WRITE_PROTECT_: return permission_denied;
|
||||
|
||||
case WSAEACCES_: return permission_denied;
|
||||
case WSAEACCES_: return permission_denied;
|
||||
case WSAEADDRINUSE_: return address_in_use;
|
||||
case WSAEADDRNOTAVAIL_: return address_not_available;
|
||||
case WSAEAFNOSUPPORT_: return address_family_not_supported;
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
|
||||
#include <boost/system/detail/system_category.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/generic_category.hpp>
|
||||
#include <boost/system/api_config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
||||
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
||||
@@ -37,7 +35,7 @@ inline boost::system::error_condition boost::system::detail::system_error_catego
|
||||
}
|
||||
else
|
||||
{
|
||||
return error_condition( e2, generic_category() );
|
||||
return error_condition( boost::system::detail::generic_value_tag( e2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,18 +52,10 @@ inline char const * boost::system::detail::system_error_category::message( int e
|
||||
#else // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#include <boost/system/detail/generic_category_message.hpp>
|
||||
#include <boost/system/detail/is_generic_value.hpp>
|
||||
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
{
|
||||
if( is_generic_value( ev ) )
|
||||
{
|
||||
return error_condition( ev, generic_category() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return error_condition( ev, *this );
|
||||
}
|
||||
return error_condition( boost::system::detail::generic_value_tag( ev ) );
|
||||
}
|
||||
|
||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/winapi/error_handling.hpp>
|
||||
#include <boost/winapi/character_code_conversion.hpp>
|
||||
#include <boost/winapi/local_memory.hpp>
|
||||
@@ -27,35 +28,12 @@ namespace system
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
||||
|
||||
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
||||
{
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4996 )
|
||||
# endif
|
||||
|
||||
_snprintf( buffer, len - 1, "Unknown error (%d)", ev );
|
||||
|
||||
buffer[ len - 1 ] = 0;
|
||||
return buffer;
|
||||
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
|
||||
{
|
||||
std::snprintf( buffer, len, "Unknown error (%d)", ev );
|
||||
detail::snprintf( buffer, len, "Unknown error (%d)", ev );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline boost::winapi::UINT_ message_cp_win32()
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_USE_UTF8)
|
||||
|
||||
@@ -17,38 +17,5 @@
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/system/detail/throws.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
// non-member functions of error_code and error_condition
|
||||
|
||||
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||
#endif
|
||||
|
||||
// This header is effectively empty for compiles on operating systems where
|
||||
// it is not applicable.
|
||||
|
||||
|
||||
@@ -18,16 +18,6 @@
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
//// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on
|
||||
//// either of those platforms include the full windows.h
|
||||
//
|
||||
//#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
//#include <windows.h>
|
||||
//#else
|
||||
//#include <winerror.h>
|
||||
//#endif
|
||||
|
||||
#include <boost/winapi/error_codes.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -82,7 +72,8 @@ namespace boost
|
||||
wrong_disk = boost::winapi::ERROR_WRONG_DISK_,
|
||||
sharing_buffer_exceeded = boost::winapi::ERROR_SHARING_BUFFER_EXCEEDED_,
|
||||
handle_eof = boost::winapi::ERROR_HANDLE_EOF_,
|
||||
handle_disk_full= boost::winapi::ERROR_HANDLE_DISK_FULL_,
|
||||
handle_disk_full = boost::winapi::ERROR_HANDLE_DISK_FULL_,
|
||||
not_supported = boost::winapi::ERROR_NOT_SUPPORTED_,
|
||||
rem_not_list = boost::winapi::ERROR_REM_NOT_LIST_,
|
||||
dup_name = boost::winapi::ERROR_DUP_NAME_,
|
||||
bad_net_path = boost::winapi::ERROR_BAD_NETPATH_,
|
||||
@@ -94,7 +85,7 @@ namespace boost
|
||||
broken_pipe = boost::winapi::ERROR_BROKEN_PIPE_,
|
||||
open_failed = boost::winapi::ERROR_OPEN_FAILED_,
|
||||
buffer_overflow = boost::winapi::ERROR_BUFFER_OVERFLOW_,
|
||||
disk_full= boost::winapi::ERROR_DISK_FULL_,
|
||||
disk_full = boost::winapi::ERROR_DISK_FULL_,
|
||||
// ...
|
||||
lock_failed = boost::winapi::ERROR_LOCK_FAILED_,
|
||||
busy = boost::winapi::ERROR_BUSY_,
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
"description": "Operating system support, including the diagnostics support that will be part of the C++0x standard library.",
|
||||
"category": [
|
||||
"System"
|
||||
]
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
||||
@@ -69,3 +69,32 @@ lib(boost_system_std_single_instance_lib2 STD_SINGLE_INSTANCE_DYN_LINK std_singl
|
||||
|
||||
system_run(std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp)
|
||||
boost_test(SOURCES std_single_instance_test.cpp NAME std_single_instance_test_lib LINK_LIBRARIES boost_system_std_single_instance_lib1 boost_system_std_single_instance_lib2)
|
||||
|
||||
boost_test(TYPE run SOURCES is_error_code_enum_test.cpp)
|
||||
boost_test(TYPE run SOURCES is_error_condition_enum_test.cpp)
|
||||
boost_test(TYPE run SOURCES errc_test.cpp)
|
||||
boost_test(TYPE run SOURCES errc_test2.cpp)
|
||||
boost_test(TYPE run SOURCES error_category_test2.cpp)
|
||||
boost_test(TYPE run SOURCES error_condition_test.cpp)
|
||||
boost_test(TYPE run SOURCES error_condition_test2.cpp)
|
||||
boost_test(TYPE run SOURCES generic_category_test2.cpp)
|
||||
boost_test(TYPE run SOURCES generic_category_test3.cpp)
|
||||
boost_test(TYPE run SOURCES system_category_test2.cpp)
|
||||
boost_test(TYPE run SOURCES system_category_test3.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES windows_error_test.cpp)
|
||||
boost_test(TYPE run SOURCES cygwin_error_test.cpp)
|
||||
boost_test(TYPE run SOURCES linux_error_test.cpp)
|
||||
|
||||
boost_test(TYPE link SOURCES errc_test3.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES snprintf_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES std_interop_test2.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test3.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test4.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test5.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test6.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test7.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test8.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test9.cpp)
|
||||
|
||||
@@ -85,3 +85,26 @@ run generic_category_test2.cpp ;
|
||||
run generic_category_test3.cpp ;
|
||||
run system_category_test2.cpp ;
|
||||
run system_category_test3.cpp ;
|
||||
|
||||
run windows_error_test.cpp ;
|
||||
run cygwin_error_test.cpp ;
|
||||
run linux_error_test.cpp ;
|
||||
|
||||
link errc_test3.cpp ;
|
||||
|
||||
run snprintf_test.cpp ;
|
||||
|
||||
run std_interop_test2.cpp ;
|
||||
run std_interop_test3.cpp ;
|
||||
run std_interop_test4.cpp ;
|
||||
run std_interop_test5.cpp
|
||||
: : :
|
||||
# crash on xenial, but the real g++ 4.8 on both centos 7 and trusty works
|
||||
<toolset>gcc-4.8:<build>no
|
||||
<toolset>gcc-4.9:<build>no
|
||||
;
|
||||
|
||||
run std_interop_test6.cpp ;
|
||||
run std_interop_test7.cpp ;
|
||||
run std_interop_test8.cpp ;
|
||||
run std_interop_test9.cpp ;
|
||||
|
||||
@@ -7,12 +7,11 @@ cmake_minimum_required(VERSION 3.5...3.16)
|
||||
project(cmake_install_test LANGUAGES CXX)
|
||||
|
||||
find_package(boost_system REQUIRED)
|
||||
find_package(boost_core REQUIRED)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::system Boost::core)
|
||||
add_executable(main main.cpp)
|
||||
target_link_libraries(main Boost::system)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
||||
44
test/cmake_install_test/main.cpp
Normal file
44
test/cmake_install_test/main.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright 2017, 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system.hpp>
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
|
||||
#define BOOST_TEST(expr) assert(expr)
|
||||
#define BOOST_TEST_EQ(x1, x2) assert((x1)==(x2))
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::system::error_category const & bt = boost::system::generic_category();
|
||||
|
||||
int ev = ENOENT;
|
||||
|
||||
boost::system::error_code bc( ev, bt );
|
||||
|
||||
BOOST_TEST_EQ( bc.value(), ev );
|
||||
BOOST_TEST_EQ( &bc.category(), &bt );
|
||||
|
||||
boost::system::error_condition bn = bt.default_error_condition( ev );
|
||||
|
||||
BOOST_TEST_EQ( bn.value(), ev );
|
||||
BOOST_TEST_EQ( &bn.category(), &bt );
|
||||
|
||||
BOOST_TEST( bt.equivalent( ev, bn ) );
|
||||
|
||||
BOOST_TEST( bc == bn );
|
||||
|
||||
boost::system::error_code bc2 = make_error_code( boost::system::errc::no_such_file_or_directory );
|
||||
|
||||
BOOST_TEST_EQ( bc2, bc );
|
||||
BOOST_TEST_EQ( bc2.value(), ev );
|
||||
BOOST_TEST_EQ( &bc.category(), &bt );
|
||||
|
||||
boost::system::system_error x( bc, "prefix" );
|
||||
|
||||
BOOST_TEST_EQ( x.code(), bc );
|
||||
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
|
||||
}
|
||||
29
test/cygwin_error_test.cpp
Normal file
29
test/cygwin_error_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/cygwin_error.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(__CYGWIN__)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, __CYGWIN__ is not defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
sys::error_code ec = sys::cygwin_error::no_package;
|
||||
|
||||
BOOST_TEST_EQ( ec, sys::cygwin_error::no_package );
|
||||
BOOST_TEST_EQ( ec, sys::error_code( ENOPKG, sys::system_category() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
34
test/errc_test3.cpp
Normal file
34
test/errc_test3.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/errc.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
make_error_code( boost::system::errc::success ).value();
|
||||
make_error_code( boost::system::errc::success ).category();
|
||||
make_error_code( boost::system::errc::success ).default_error_condition();
|
||||
make_error_code( boost::system::errc::success ).message();
|
||||
make_error_code( boost::system::errc::success ).failed();
|
||||
make_error_code( boost::system::errc::success ).clear();
|
||||
|
||||
make_error_condition( boost::system::errc::success ).value();
|
||||
make_error_condition( boost::system::errc::success ).category();
|
||||
make_error_condition( boost::system::errc::success ).message();
|
||||
make_error_condition( boost::system::errc::success ).failed();
|
||||
make_error_condition( boost::system::errc::success ).clear();
|
||||
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).value();
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).category();
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).default_error_condition();
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).message();
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).failed();
|
||||
make_error_code( boost::system::errc::no_such_file_or_directory ).clear();
|
||||
|
||||
make_error_condition( boost::system::errc::no_such_file_or_directory ).value();
|
||||
make_error_condition( boost::system::errc::no_such_file_or_directory ).category();
|
||||
make_error_condition( boost::system::errc::no_such_file_or_directory ).message();
|
||||
make_error_condition( boost::system::errc::no_such_file_or_directory ).failed();
|
||||
make_error_condition( boost::system::errc::no_such_file_or_directory ).clear();
|
||||
}
|
||||
@@ -11,11 +11,8 @@
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/cygwin_error.hpp>
|
||||
#include <boost/system/linux_error.hpp>
|
||||
#include <boost/system/windows_error.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -294,29 +291,7 @@ int main( int, char ** )
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
||||
std::cout << "Cygwin tests...\n";
|
||||
ec = cygwin_error::no_package;
|
||||
BOOST_TEST( ec == cygwin_error::no_package );
|
||||
BOOST_TEST( ec == error_code( ENOPKG, system_category() ) );
|
||||
BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category() ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
||||
|
||||
# elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||
|
||||
std::cout << "Linux tests...\n";
|
||||
ec = linux_error::dot_dot_error;
|
||||
BOOST_TEST( ec == linux_error::dot_dot_error );
|
||||
BOOST_TEST( ec == error_code( EDOTDOT, system_category() ) );
|
||||
BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category() ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
||||
29
test/linux_error_test.cpp
Normal file
29
test/linux_error_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/linux_error.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(__linux__)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, __linux__ is not defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
sys::error_code ec = sys::linux_error::dot_dot_error;
|
||||
|
||||
BOOST_TEST_EQ( ec, sys::linux_error::dot_dot_error );
|
||||
BOOST_TEST_EQ( ec, sys::error_code( EDOTDOT, sys::system_category() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,15 +1,10 @@
|
||||
|
||||
// Copyright 2017 Peter Dimov.
|
||||
//
|
||||
// Copyright 2017, 2021 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
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
@@ -33,6 +28,12 @@ int main()
|
||||
|
||||
BOOST_TEST( bc == bn );
|
||||
|
||||
boost::system::error_code bc2 = make_error_code( boost::system::errc::no_such_file_or_directory );
|
||||
|
||||
BOOST_TEST_EQ( bc2, bc );
|
||||
BOOST_TEST_EQ( bc2.value(), ev );
|
||||
BOOST_TEST_EQ( &bc.category(), &bt );
|
||||
|
||||
boost::system::system_error x( bc, "prefix" );
|
||||
|
||||
BOOST_TEST_EQ( x.code(), bc );
|
||||
|
||||
60
test/snprintf_test.cpp
Normal file
60
test/snprintf_test.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
char buffer[ 64 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 64 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 15 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 14 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151.." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 5 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...x" );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 1 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "" );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 1 ] = { 'Q' };
|
||||
boost::system::detail::snprintf( buffer, 0, "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_EQ( buffer[0], 'Q' );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
98
test/std_interop_test2.cpp
Normal file
98
test/std_interop_test2.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
void f1( std::error_code ec, int value, std::error_category const& category )
|
||||
{
|
||||
BOOST_TEST_EQ( ec.value(), value );
|
||||
BOOST_TEST_EQ( &ec.category(), &category );
|
||||
}
|
||||
|
||||
void f2( std::error_code const& ec, int value, std::error_category const& category )
|
||||
{
|
||||
BOOST_TEST_EQ( ec.value(), value );
|
||||
BOOST_TEST_EQ( &ec.category(), &category );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::system_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::system_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::generic_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( ENOENT, boost::system::generic_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
79
test/std_interop_test3.cpp
Normal file
79
test/std_interop_test3.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::error_code e1;
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( !e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::system_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 0, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( !e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( ENOENT, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = make_error_code( std::errc::no_such_file_or_directory );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
89
test/std_interop_test4.cpp
Normal file
89
test/std_interop_test4.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
void f( std::error_code& e1, std::error_code e2 )
|
||||
{
|
||||
e1 = e2;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2;
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 0, std::system_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 5, std::system_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 0, std::generic_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( ENOENT, std::generic_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
108
test/std_interop_test5.cpp
Normal file
108
test/std_interop_test5.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::error_code e1;
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::system_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 0, std::generic_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::generic_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
129
test/std_interop_test6.cpp
Normal file
129
test/std_interop_test6.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::system_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::system_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::generic_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::generic_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
52
test/std_interop_test7.cpp
Normal file
52
test/std_interop_test7.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( boost::system::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == boost::system::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != boost::system::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == std::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != std::errc::bad_address );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( std::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == boost::system::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != boost::system::errc::bad_address );
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40800 && BOOST_GCC < 50000
|
||||
|
||||
// fails on g++ 4.8.5 and g++ 4.9.4 from ubuntu-toolchain-r-test for unknown reasons
|
||||
// works on the system g++ 4.8.4 on Trusty and the system g++ 4.8.5 on CentOS 7
|
||||
|
||||
#else
|
||||
BOOST_TEST( e1 == std::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != std::errc::bad_address );
|
||||
#endif
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
82
test/std_interop_test8.cpp
Normal file
82
test/std_interop_test8.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
my_enoent = ENOENT
|
||||
};
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 70000
|
||||
|
||||
// g++ 6 and earlier do not allow specializations outside the namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<> struct is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#else
|
||||
|
||||
template<> struct boost::system::is_error_condition_enum<my_errc>: std::true_type {};
|
||||
template<> struct std::is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
boost::system::error_condition make_error_condition( my_errc e )
|
||||
{
|
||||
return boost::system::error_condition( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
boost::system::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return boost::system::error_code( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( my_enoent );
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = make_error_code( my_enoent );
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
77
test/std_interop_test9.cpp
Normal file
77
test/std_interop_test9.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
my_enoent = ENOENT
|
||||
};
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 70000
|
||||
|
||||
// g++ 6 and earlier do not allow specializations outside the namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#else
|
||||
|
||||
template<> struct boost::system::is_error_code_enum<my_errc>: std::true_type {};
|
||||
template<> struct std::is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
boost::system::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return boost::system::error_code( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = my_enoent;
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = my_enoent;
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,9 @@ int main()
|
||||
|
||||
// default_error_condition
|
||||
BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition() );
|
||||
BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
|
||||
|
||||
// No longer holds; returns a generic condition
|
||||
// BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
|
||||
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
|
||||
|
||||
31
test/windows_error_test.cpp
Normal file
31
test/windows_error_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/windows_error.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_WINDOWS_API)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_WINDOWS_API is not defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
sys::error_code ec = sys::windows_error::invalid_function;
|
||||
|
||||
BOOST_TEST_EQ( ec, sys::windows_error::invalid_function );
|
||||
BOOST_TEST_EQ( ec, sys::error_code( ERROR_INVALID_FUNCTION, sys::system_category() ) );
|
||||
BOOST_TEST( ec == make_error_condition( sys::errc::function_not_supported ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user