mirror of
https://github.com/boostorg/system.git
synced 2025-06-25 12:01:40 +02:00
Compare commits
115 Commits
boost-1.83
...
develop
Author | SHA1 | Date | |
---|---|---|---|
7a49a5d80d | |||
a0597f4872 | |||
485be93281 | |||
ee0b15efc4 | |||
09f4eb87e2 | |||
3e5ce27719 | |||
40bdcea2e5 | |||
19bcfebf37 | |||
6d58d0bb76 | |||
a664cd1de6 | |||
e8a089b664 | |||
75e1a1e28b | |||
5feb280612 | |||
fc3ab6db97 | |||
91929719bd | |||
8d0fa396b8 | |||
671d0ad41b | |||
5d5ecb74a7 | |||
41ff095c0a | |||
38d63aaf7c | |||
d1fb7554c5 | |||
c63bca6eda | |||
bef2c5ef6a | |||
341f960e72 | |||
4d4f906548 | |||
8a92683012 | |||
be5a8ffa80 | |||
d032ab91fd | |||
9b82082f76 | |||
3c293f8740 | |||
2feb94ac07 | |||
8f319f30c6 | |||
d09b2f5f1d | |||
01d46f597e | |||
93852d1a7e | |||
4aeebd2173 | |||
96fef94580 | |||
75ab18c9fd | |||
f9a4655ae7 | |||
f6fcb1b690 | |||
27a5096b6c | |||
9cc66841c4 | |||
2fc720a1cb | |||
73de83b8f7 | |||
310bf1d544 | |||
f18edb3d24 | |||
a9659f4318 | |||
2b14b9a96a | |||
c7a0ce3349 | |||
cedf6eb581 | |||
ab368822a6 | |||
293174a1d3 | |||
5c1d0df893 | |||
3f2f87f734 | |||
6caa346ba5 | |||
a5aec941ca | |||
7f640b92fe | |||
626263c23f | |||
53ce7e9f53 | |||
ff47c6782f | |||
abbfd46517 | |||
128fd9341f | |||
e0b0118406 | |||
3ded81eed0 | |||
80e019069c | |||
e368c2863d | |||
00fb79f174 | |||
44582f3c3c | |||
f08e363c0e | |||
1474498ccf | |||
b0304ad0b2 | |||
9974d92675 | |||
945b0591dd | |||
1f1e4e0400 | |||
1a0b9a46a8 | |||
f132dca4a9 | |||
81a9952695 | |||
b877f65f80 | |||
aa80e0bdcd | |||
0b60b13618 | |||
7dacf5be11 | |||
c3cd1d5ea9 | |||
2bea482605 | |||
48f95f0035 | |||
16d20175bc | |||
2aa5d4d97f | |||
18edbf75d0 | |||
52220a0351 | |||
ffa67ab005 | |||
d8399efcac | |||
8bc32b7267 | |||
d11dd4b396 | |||
ca5bca39ce | |||
a58115cb50 | |||
1bc08296de | |||
25479216b3 | |||
54d3b253b1 | |||
194b84e663 | |||
47a08cb35b | |||
7ffd63d54c | |||
92c24da9a1 | |||
dc73ca428b | |||
c1fa3619b6 | |||
0cd351014b | |||
d38e54d4c3 | |||
fa3331412d | |||
b899c49ae8 | |||
61a0e244da | |||
eb788615de | |||
84fd43e14a | |||
b0ef682e3d | |||
c360ff1b1c | |||
951b3fe7b4 | |||
a57c568324 | |||
4843453528 |
184
.drone.jsonnet
184
.drone.jsonnet
@ -32,6 +32,8 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
|
||||
commands:
|
||||
[
|
||||
'set -e',
|
||||
'uname -a',
|
||||
'echo $DRONE_STAGE_MACHINE',
|
||||
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
|
||||
] +
|
||||
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
|
||||
@ -97,206 +99,256 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
|
||||
[
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.4",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
|
||||
"g++-4.4",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
"Linux 16.04 GCC 4.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '11' },
|
||||
"g++-4.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.6",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x' },
|
||||
"g++-4.6",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.7",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x' },
|
||||
"g++-4.7",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.8*",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 14.04 GCC 4.9",
|
||||
"cppalliance/droneubuntu1404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' },
|
||||
"Linux 16.04 GCC 4.9",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11' },
|
||||
"g++-4.9",
|
||||
[ "ppa:ubuntu-toolchain-r/test" ],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 5*",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 6",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '11,14' },
|
||||
"g++-6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 7* 32/64",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17', ADDRMD: '32,64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 18.04 GCC 8",
|
||||
"cppalliance/droneubuntu1804:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '11,14,17' },
|
||||
"g++-8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 32",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* 64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* ARM64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
|
||||
arch="arm64",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9* S390x",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
|
||||
arch="s390x",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '32' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '64' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 32",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32 ASAN",
|
||||
"Linux 22.04 GCC 12 32",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' },
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 64 ASAN",
|
||||
"Linux 22.04 GCC 12 64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' },
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 32 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 64 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 13 32 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-13-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 GCC 14 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"g++-14-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.5",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '11' },
|
||||
"clang-3.5",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.6",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '11,14' },
|
||||
"clang-3.6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '11,14' },
|
||||
"clang-3.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '11,14' },
|
||||
"clang-3.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 13",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '11,14,17,20' },
|
||||
"clang-13",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 UBSAN",
|
||||
"Linux 22.04 Clang 14",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
|
||||
"clang-14",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '11,14,17,20' },
|
||||
"clang-14",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 15",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-15",
|
||||
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 16",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 17",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.10 Clang 19",
|
||||
"cppalliance/droneubuntu2410:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-19",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + asan,
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 12.4 Xcode 13.4.1 ASAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
"Windows VS2015 msvc-14.0",
|
||||
"cppalliance/dronevs2015",
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' },
|
||||
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
|
||||
),
|
||||
|
||||
windows_pipeline(
|
||||
|
@ -5,6 +5,7 @@
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
set -ex
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
DRONE_BUILD_DIR=$(pwd)
|
||||
|
||||
|
163
.github/workflows/ci.yml
vendored
163
.github/workflows/ci.yml
vendored
@ -18,134 +18,187 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-10
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-22.04
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
install: g++-13
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
install: g++-14
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17"
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
compiler: clang++-15
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:22.04
|
||||
os: ubuntu-latest
|
||||
install: clang-15
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-11
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-12
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
- toolset: clang
|
||||
compiler: clang++-18
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:24.10
|
||||
os: ubuntu-latest
|
||||
install: clang-19
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-13
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-14
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
container:
|
||||
image: ${{matrix.container}}
|
||||
volumes:
|
||||
- /node20217:/node20217:rw,rshared
|
||||
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python git g++
|
||||
apt-get -y install sudo python3 git g++ curl xz-utils
|
||||
|
||||
- name: Install nodejs20glibc2.17
|
||||
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
|
||||
run: |
|
||||
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
|
||||
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
|
||||
ldd /__e/node20/bin/node
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -165,7 +218,7 @@ jobs:
|
||||
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
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
@ -197,18 +250,18 @@ jobs:
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@ -245,13 +298,15 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@ -292,13 +347,15 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@ -349,13 +406,15 @@ jobs:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@ -408,7 +467,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@ -457,7 +516,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@ -524,7 +583,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
|
@ -1,8 +1,8 @@
|
||||
# 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
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
cmake_minimum_required(VERSION 3.8...3.20)
|
||||
|
||||
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@ -20,6 +20,8 @@ target_link_libraries(boost_system
|
||||
Boost::winapi
|
||||
)
|
||||
|
||||
target_compile_features(boost_system INTERFACE cxx_std_11)
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
|
||||
file(GLOB_RECURSE boost_system_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
|
||||
@ -29,7 +31,7 @@ if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio
|
||||
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
|
39
appveyor.yml
39
appveyor.yml
@ -14,37 +14,26 @@ branches:
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_SUBDIR: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;
|
||||
TOOLSET: gcc
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_SUBDIR: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_INSTALL: 1
|
||||
|
||||
install:
|
||||
|
25
build.jam
Normal file
25
build.jam
Normal file
@ -0,0 +1,25 @@
|
||||
# Copyright 2023-2024 René Ferdinand Rivera Morell
|
||||
# Copyright 2024 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/variant2//boost_variant2
|
||||
/boost/winapi//boost_winapi
|
||||
;
|
||||
|
||||
project /boost/system ;
|
||||
|
||||
explicit
|
||||
[ alias boost_system : build//boost_system ]
|
||||
[ alias all : boost_system test ]
|
||||
;
|
||||
|
||||
call-if : boost-library system
|
||||
: install boost_system
|
||||
;
|
@ -1,25 +1,20 @@
|
||||
# Boost System Library Build Jamfile
|
||||
|
||||
# (C) Copyright Beman Dawes 2002, 2006
|
||||
|
||||
# Copyright 2002, 2006 Beman Dawes
|
||||
# Copyright 2024 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
# See library home page at https://www.boost.org/libs/system
|
||||
|
||||
project boost/system
|
||||
: source-location ../src
|
||||
: usage-requirements # pass these requirement to dependents (i.e. users)
|
||||
project
|
||||
: common-requirements
|
||||
<include>../include
|
||||
<library>$(boost_dependencies)
|
||||
<link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
|
||||
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
|
||||
<define>BOOST_SYSTEM_NO_LIB=1
|
||||
;
|
||||
|
||||
SOURCES = error_code ;
|
||||
|
||||
lib boost_system
|
||||
: $(SOURCES).cpp
|
||||
: <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
|
||||
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
|
||||
;
|
||||
|
||||
boost-install boost_system ;
|
||||
lib boost_system : ../src/$(SOURCES).cpp ;
|
||||
|
@ -8,6 +8,26 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.86
|
||||
|
||||
* Support `result<T> & fv`, where `fv` returns `void`.
|
||||
* Support `result<void> &= fv;`, where `fv` returns `void`.
|
||||
|
||||
## Changes in Boost 1.85
|
||||
|
||||
* {cpp}03 is no longer supported; a {cpp}11 compiler is required. (This includes GCC 4.8 or later, and MSVC 14.0 (VS 2015) or later.)
|
||||
* The deprecated header `boost/system/cygwin_error.hpp` has been removed.
|
||||
* The original and obsolete (32 bit) MinGW is no longer supported. MinGW-w64 (both 64 and 32 bit) is still supported.
|
||||
* `operator&` now works for `result<void>` (by way of taking a nullary function.)
|
||||
* Added `operator|=` for `result`.
|
||||
|
||||
## Changes in Boost 1.84
|
||||
|
||||
* Added support for `result<U&, E>`.
|
||||
* Added `operator|` for `result`.
|
||||
* Added `operator&` for `result`.
|
||||
* Added `operator&=` for `result`.
|
||||
|
||||
## Changes in Boost 1.81
|
||||
|
||||
* The macro `BOOST_SYSTEM_DISABLE_THREADS` can now be defined to disable
|
||||
|
@ -12,13 +12,6 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
# Reference
|
||||
:idprefix: ref_
|
||||
|
||||
## Use of {cpp}11 and {cpp}14 Features
|
||||
|
||||
The library is documented to use several {cpp}11 and {cpp}14 features,
|
||||
including `noexcept`, explicit conversion operators and `constexpr`. The
|
||||
actual implementation uses {cpp}11 and {cpp}14 features only when they are
|
||||
available, and otherwise falls back on {cpp}03 features.
|
||||
|
||||
## Macros
|
||||
|
||||
When `BOOST_SYSTEM_ENABLE_DEPRECATED` is defined, the library provides
|
||||
@ -1517,6 +1510,38 @@ constexpr in_place_error_t in_place_error{};
|
||||
|
||||
template<class T, class E = error_code> class result;
|
||||
template<class E> class result<void, E>;
|
||||
template<class U, class E> class result<U&, E>;
|
||||
|
||||
// operator|
|
||||
|
||||
template<class T, class E, class U> T operator|( result<T, E> const& r, U&& u );
|
||||
template<class T, class E, class U> T operator|( result<T, E>&& r, U&& u );
|
||||
|
||||
template<class T, class E, class F> T operator|( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F> T operator|( result<T, E>&& r, F&& f );
|
||||
|
||||
template<class T, class E, class F, class R = ...> R operator|( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F, class R = ...> R operator|( result<T, E>&& r, F&& f );
|
||||
template<class E, class F, class R = ...> R operator|( result<void, E> const& r, F&& f );
|
||||
template<class E, class F, class R = ...> R operator|( result<void, E>&& r, F&& f );
|
||||
|
||||
// operator&
|
||||
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<U, E> operator&( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<U, E> operator&( result<T, E>&& r, F&& f );
|
||||
|
||||
template<class T, class E, class F, class R = ...> R operator&( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F, class R = ...> R operator&( result<T, E>&& r, F&& f );
|
||||
|
||||
// operator&=
|
||||
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f );
|
||||
|
||||
template<class T, class E, class F, class R = ...>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f );
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
@ -1713,7 +1738,7 @@ Effects: ::
|
||||
ensures that `*this` holds the error `E( std::forward<A>(a)... )`.
|
||||
- Otherwise, this constructor does not participate in overload resolution.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `sizeof...(T) > 0`.
|
||||
This constructor is only enabled when `sizeof...(A) > 0`.
|
||||
|
||||
```
|
||||
template<class... A>
|
||||
@ -1747,7 +1772,7 @@ template<class T2, class E2>
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
If `r2.has_value()` is `true`, `*this` holds the value `T( *r2 )`, otherwise `*this` holds the value `E( r2.error() )`.
|
||||
If `r2.has_value()` is `true`, `*this` holds the value `T( *r2 )`, otherwise `*this` holds the error `E( r2.error() )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_convertible<T2, T>::value && std::is_convertible<E2, E>::value` is `true`.
|
||||
|
||||
@ -1759,7 +1784,7 @@ template<class T2, class E2>
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
If `r2.has_value()` is `true`, `*this` holds the value `T( std::move( *r2 ) )`, otherwise `*this` holds the value `E( r2.error() )`.
|
||||
If `r2.has_value()` is `true`, `*this` holds the value `T( std::move( *r2 ) )`, otherwise `*this` holds the error `E( r2.error() )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_convertible<T2, T>::value && std::is_convertible<E2, E>::value` is `true`.
|
||||
|
||||
@ -1961,6 +1986,9 @@ public:
|
||||
template<class... A>
|
||||
constexpr result( in_place_error_t, A&&... a );
|
||||
|
||||
template<class E2>
|
||||
constexpr result( result<void, E2> const& r2 );
|
||||
|
||||
// queries
|
||||
|
||||
constexpr bool has_value() const noexcept;
|
||||
@ -2032,7 +2060,7 @@ Effects: ::
|
||||
ensures that `*this` holds the error `E( std::forward<A>(a)... )`.
|
||||
- Otherwise, this constructor does not participate in overload resolution.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `sizeof...(T) > 0`.
|
||||
This constructor is only enabled when `sizeof...(A) > 0`.
|
||||
|
||||
```
|
||||
template<class... A>
|
||||
@ -2056,6 +2084,18 @@ Ensures: ::
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_constructible<E, A...>::value` is `true`.
|
||||
|
||||
```
|
||||
template<class E2>
|
||||
constexpr result( result<void, E2> const& r2 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
If `r2.has_value()` is `true`, `*this` holds an unspecified value, otherwise `*this` holds the error `E( r2.error() )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_convertible<E2, E>::value` is `true`.
|
||||
|
||||
#### Queries
|
||||
|
||||
```
|
||||
@ -2201,6 +2241,637 @@ Effects: ::
|
||||
Returns: ::
|
||||
`os`.
|
||||
|
||||
### result<U&, E>
|
||||
|
||||
```
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
template<class U, class E> class result<U&, E>
|
||||
{
|
||||
public:
|
||||
|
||||
using value_type = U&;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
// constructors
|
||||
|
||||
template<class A>
|
||||
constexpr result( A&& a ) noexcept;
|
||||
|
||||
template<class... A>
|
||||
constexpr result( A&&... a );
|
||||
|
||||
template<class A>
|
||||
constexpr result( in_place_value_t, A&& a ) noexcept;
|
||||
|
||||
template<class... A>
|
||||
constexpr result( in_place_error_t, A&&... a );
|
||||
|
||||
template<class U2, class E2>
|
||||
constexpr result( result<U2&, E2> const& r2 );
|
||||
|
||||
// queries
|
||||
|
||||
constexpr bool has_value() const noexcept;
|
||||
constexpr bool has_error() const noexcept;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
|
||||
// checked value access
|
||||
|
||||
constexpr U& value( boost::source_location const & loc =
|
||||
BOOST_CURRENT_LOCATION ) const;
|
||||
|
||||
// unchecked value access
|
||||
|
||||
constexpr U* operator->() const noexcept;
|
||||
constexpr U& operator*() const noexcept;
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
|
||||
// emplace
|
||||
|
||||
template<class A>
|
||||
constexpr U& emplace( A&& a ) noexcept;
|
||||
|
||||
// swap
|
||||
|
||||
constexpr void swap( result& r );
|
||||
friend constexpr void swap( result & r1, result & r2 );
|
||||
|
||||
// equality
|
||||
|
||||
friend constexpr bool operator==( result const & r1, result const & r2 );
|
||||
friend constexpr bool operator!=( result const & r1, result const & r2 );
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
#### Constructors
|
||||
|
||||
```
|
||||
template<class A>
|
||||
constexpr result( A&& a ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds the reference `static_cast<U&>( std::forward<A>(a) )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `A` is `B&` and `std::is_convertible<B*, U*>::value` is `true`.
|
||||
|
||||
```
|
||||
template<class... A>
|
||||
constexpr result( A&&... a );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
- If `std::is_constructible<E, A...>::value && !std::is_constructible<U&, A...>::value`,
|
||||
ensures that `*this` holds the error `E( std::forward<A>(a)... )`.
|
||||
- Otherwise, this constructor does not participate in overload resolution.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `sizeof...(A) > 0`.
|
||||
|
||||
```
|
||||
template<class A>
|
||||
constexpr result( in_place_value_t, A&& a ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds the reference `static_cast<U&>( std::forward<A>(a) )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `A` is `B&` and `std::is_convertible<B*, U*>::value` is `true`.
|
||||
|
||||
```
|
||||
template<class... A>
|
||||
constexpr result( in_place_error_t, A&&... a );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds the error `E( std::forward<A>(a)... )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_constructible<E, A...>::value` is `true`.
|
||||
|
||||
```
|
||||
template<class U2, class E2>
|
||||
constexpr result( result<U2&, E2> const& r2 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
If `r2.has_value()` is `true`, `*this` holds the reference `static_cast<U&>( *r2 )`, otherwise `*this` holds the error `E( r2.error() )`.
|
||||
Remarks: ::
|
||||
This constructor is only enabled when `std::is_convertible<U2*, U*>::value && std::is_convertible<E2, E>::value` is `true`.
|
||||
|
||||
#### Queries
|
||||
|
||||
```
|
||||
constexpr bool has_value() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`true` when `*this` holds a value, `false` otherwise.
|
||||
|
||||
```
|
||||
constexpr bool has_error() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`!has_value()`.
|
||||
|
||||
```
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`has_value()`.
|
||||
|
||||
#### Checked Value Access
|
||||
|
||||
```
|
||||
constexpr U& value(
|
||||
boost::source_location const & loc = BOOST_CURRENT_LOCATION ) const;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
If `*this` holds a reference, returns it. Otherwise,
|
||||
calls `throw_exception_from_error`, passing it a reference to
|
||||
the held error, and `loc`.
|
||||
|
||||
#### Unchecked Value Access
|
||||
|
||||
```
|
||||
constexpr U* operator->() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
If `*this` holds a reference, a pointer to its referent. Otherwise, `nullptr`.
|
||||
|
||||
```
|
||||
constexpr U& operator*() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Requires: :: `*this` holds a reference.
|
||||
Returns: ::
|
||||
`*operator\->()`.
|
||||
|
||||
#### Error Access
|
||||
|
||||
```
|
||||
constexpr E error() const &;
|
||||
constexpr E error() &&;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
If `*this` holds an error, returns it. Otherwise, returns `E()`.
|
||||
|
||||
#### emplace
|
||||
|
||||
```
|
||||
template<class A>
|
||||
constexpr U& emplace( A&& a ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds the reference `static_cast<U&>( std::forward<A>(a)... )`.
|
||||
Returns: ::
|
||||
The contained reference.
|
||||
Remarks: ::
|
||||
This function is only enabled when `A` is `B&` and `std::is_convertible<B*, U*>::value` is `true`.
|
||||
|
||||
#### swap
|
||||
|
||||
```
|
||||
constexpr void swap( result& r );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
Exchanges the contents of `*this` and `r`.
|
||||
|
||||
```
|
||||
friend constexpr void swap( result & r1, result & r2 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
Exchanges the contents of `r1` and `r2`.
|
||||
|
||||
#### Equality
|
||||
|
||||
```
|
||||
friend constexpr bool operator==( result const & r1, result const & r2 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
- If `r1` holds a reference `t1` and `r2` holds a reference `t2`, returns `t1 == t2`.
|
||||
- If `r1` holds an error `e1` and `r2` holds an error `e2`, returns `e1 == e2`.
|
||||
- Otherwise, returns `false`.
|
||||
|
||||
```
|
||||
friend constexpr bool operator!=( result const & r1, result const & r2 );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`!( r1 == r2 )`.
|
||||
|
||||
### Chaining
|
||||
|
||||
#### operator|
|
||||
|
||||
```
|
||||
template<class T, class E, class U> T operator|( result<T, E> const& r, U&& u );
|
||||
template<class T, class E, class U> T operator|( result<T, E>&& r, U&& u );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the value in `r`, or if `r` contains an error, a default value `u`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `*r`.
|
||||
- Otherwise, returns `u`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is convertible to `T`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
result<int> get_server_port(); // can fail
|
||||
|
||||
int get_port()
|
||||
{
|
||||
return get_server_port() | 443;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
template<class T, class E, class F> T operator|( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F> T operator|( result<T, E>&& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the value in `r`, or if `r` contains an error, a default value obtained
|
||||
by invoking the function `f`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `*r`.
|
||||
- Otherwise, returns `f()`.
|
||||
Remarks: ::
|
||||
Only enabled when `f()` is convertible to `T`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
result<int> get_server_port(); // can fail
|
||||
int get_default_port();
|
||||
|
||||
int get_port()
|
||||
{
|
||||
return get_server_port() | get_default_port;
|
||||
}
|
||||
```
|
||||
+
|
||||
Note that the right hand side is `get_default_port` and not `get_default_port()`.
|
||||
This is important; spelled this way, the function `get_default_port` is called
|
||||
only when `get_server_port_impl()` fails. If it were
|
||||
+
|
||||
```
|
||||
return get_server_port() | get_default_port();
|
||||
```
|
||||
+
|
||||
the function would have been called unconditionally.
|
||||
+
|
||||
Another, equivalent, way is to use a lambda
|
||||
+
|
||||
```
|
||||
return get_server_port() | []{ return get_default_port(); };
|
||||
```
|
||||
+
|
||||
which isn't necessary here, but would be needed for more complex expressions.
|
||||
|
||||
```
|
||||
template<class T, class E, class F, class R = ...> R operator|( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F, class R = ...> R operator|( result<T, E>&& r, F&& f );
|
||||
template<class E, class F, class R = ...> R operator|( result<void, E> const& r, F&& f );
|
||||
template<class E, class F, class R = ...> R operator|( result<void, E>&& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the value in `r`, or if `r` contains an error, another `result` obtained
|
||||
by invoking the function `f`.
|
||||
+
|
||||
Let `R` be the type of `f()`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `*r`.
|
||||
- Otherwise, returns `f()`.
|
||||
Remarks: ::
|
||||
Only enabled when `R` is an instance of `result` and `T` is convertible to `R::value_type`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
result<int> get_server_port(); // can fail
|
||||
result<int> get_default_port(); // can fail
|
||||
|
||||
int get_port()
|
||||
{
|
||||
return get_server_port() | get_default_port | 443;
|
||||
}
|
||||
```
|
||||
|
||||
#### operator|=
|
||||
|
||||
```
|
||||
template<class T, class E, class U> result<T, E>& operator|=( result<T, E>& r, U&& u );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
If `r` contains an error, assigns a value to it, constructed from `u`.
|
||||
+
|
||||
Effects: ::
|
||||
If `r.has_value()` is `false`, assigns `u` to `r`.
|
||||
Returns: ::
|
||||
`r`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is convertible to `T`.
|
||||
|
||||
```
|
||||
template<class T, class E, class F> result<T, E>& operator|=( result<T, E>& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
If `r` contains an error, assigns `f()` to it.
|
||||
+
|
||||
Effects: ::
|
||||
If `r.has_value()` is `false`, assigns `f()` to `r`.
|
||||
Returns: ::
|
||||
`r`.
|
||||
Remarks: ::
|
||||
Only enabled when the type of `f()` is either
|
||||
- convertible to `T` or
|
||||
- an instance of `result` convertible to `result<T, E>`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
result<response> query_impl( std::string_view server, request const& req );
|
||||
|
||||
result<response> query( std::vector<std::string_view> const& servers, request const& req )
|
||||
{
|
||||
result<response> r = make_error_code( errc::invalid_argument );
|
||||
|
||||
for( auto const& server: servers )
|
||||
{
|
||||
r |= std::bind( query_impl, server, std::ref( req ) );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### operator&
|
||||
|
||||
```
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<U, E> operator&( result<T, E> const& r, F&& f );
|
||||
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<U, E> operator&( result<T, E>&& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the error in `r`, or if `r` contains a value, transforms the value by calling `f` on it.
|
||||
+
|
||||
Let `U` be the type of `f(*r)`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `f(*r)`.
|
||||
- Otherwise, returns `r.error()`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is not an instance of `result`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
struct currency_type
|
||||
{
|
||||
char code_[ 4 ] = {};
|
||||
};
|
||||
|
||||
result<double> get_exchange_rate( currency_type from, currency_type to );
|
||||
|
||||
result<double> convert( double amount, currency_type from, currency_type to )
|
||||
{
|
||||
return get_exchange_rate( from, to ) & [&](double rate){ return rate * amount; };
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
template<class E, class F, class U = ...>
|
||||
result<U, E> operator&( result<void, E> const& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the error in `r`, or if `r` contains a value, replaces it with the result of calling `f`.
|
||||
+
|
||||
Let `U` be the type of `f()`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `f()`.
|
||||
- Otherwise, returns `r.error()`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is not an instance of `result`.
|
||||
|
||||
|
||||
```
|
||||
template<class T, class E, class F, class R = ...> R operator&( result<T, E> const& r, F&& f );
|
||||
template<class T, class E, class F, class R = ...> R operator&( result<T, E>&& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the error in `r`, or if `r` contains a value, another `result` obtained
|
||||
by invoking the function `f` on the value in `r`.
|
||||
+
|
||||
Let `R` be the type of `f(*r)`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `f(*r)`.
|
||||
- Otherwise, returns `r.error()`.
|
||||
Remarks: ::
|
||||
Only enabled when `R` is an instance of `result` and `E` is convertible to `R::error_type`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
struct JsonValue
|
||||
{
|
||||
result<JsonValue const&> at( std::size_t i ) const noexcept;
|
||||
result<JsonValue const&> at( std::string_view key ) const noexcept;
|
||||
template<class T> result<T> to_number() const noexcept;
|
||||
};
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
inline auto at( std::size_t i ) {
|
||||
return [=](JsonValue const& jv){ return jv.at( i ); }; }
|
||||
|
||||
inline auto at( std::string_view key ) {
|
||||
return [=](JsonValue const& jv){ return jv.at( key ); }; }
|
||||
|
||||
template<class T> inline auto to_number() {
|
||||
return [](JsonValue const& jv){ return jv.to_number<T>(); }; }
|
||||
|
||||
} // namespace helpers
|
||||
|
||||
int get_port( JsonValue const& config, int def )
|
||||
{
|
||||
using namespace helpers;
|
||||
return config.at( "servers" ) & at( 0 ) & at( "port" ) & to_number<int>() | def;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
template<class E, class F, class R = ...> R operator&( result<void, E> const& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns the error in `r`, or if `r` contains a value, another `result` obtained
|
||||
by invoking the function `f`.
|
||||
+
|
||||
Let `R` be the type of `f()`.
|
||||
+
|
||||
Effects: ::
|
||||
- If `r.has_value()` is `true`, returns `f()`.
|
||||
- Otherwise, returns `r.error()`.
|
||||
Remarks: ::
|
||||
Only enabled when `R` is an instance of `result` and `E` is convertible to `R::error_type`.
|
||||
|
||||
|
||||
#### operator&=
|
||||
|
||||
```
|
||||
template<class T, class E, class F, class U = ...>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
If `r` contains a value, replaces it with the result of invoking the function `f` on the value in `r`.
|
||||
+
|
||||
Let `U` be the type of `f(*r)`.
|
||||
+
|
||||
Effects: :: If `r.has_value()` is `true`, assigns `f(*std::move(r))` to `r`.
|
||||
Returns: :: `r`.
|
||||
Remarks: ::
|
||||
Only enabled when `U` is not an instance of `result` and is convertible to `T`.
|
||||
|
||||
```
|
||||
template<class T, class E, class F, class R = ...>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
If `r` contains a value, replaces `r` with the result of invoking the function `f` on the value in `r`.
|
||||
+
|
||||
Let `R` be the type of `f(*r)`.
|
||||
+
|
||||
Effects: :: If `r.has_value()` is `true`, assigns `f(*std::move(r))` to `r`.
|
||||
Returns: :: `r`.
|
||||
Remarks: ::
|
||||
Only enabled when `R` is an instance of `result` and is convertible to `result<T, E>`.
|
||||
Example: ::
|
||||
+
|
||||
```
|
||||
struct JsonValue
|
||||
{
|
||||
result<JsonValue const&> at( std::string_view key ) const noexcept;
|
||||
};
|
||||
|
||||
namespace helpers
|
||||
{
|
||||
|
||||
inline auto at( std::string_view key ) {
|
||||
return [=](JsonValue const& jv){ return jv.at( key ); }; }
|
||||
|
||||
} // namespace helpers
|
||||
|
||||
result<JsonValue const&> at_path( JsonValue const& jv,
|
||||
std::initializer_list<std::string_view> path )
|
||||
{
|
||||
result<JsonValue const&> r( jv );
|
||||
|
||||
using namespace helpers;
|
||||
|
||||
for( auto key: path )
|
||||
{
|
||||
r &= at( key );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
template<class E, class F, class R = ...>
|
||||
result<void, E>& operator&=( result<void, E>& r, F&& f );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
If `r` contains a value, replaces `r` with the result of invoking the function `f`.
|
||||
+
|
||||
Let `R` be the type of `f()`.
|
||||
+
|
||||
Effects: :: If `r.has_value()` is `true`, assigns `f()` to `r`.
|
||||
Returns: :: `r`.
|
||||
Remarks: ::
|
||||
Only enabled when `R` is an instance of `result<void, E2>` and `E2` is convertible to `E`.
|
||||
|
||||
## <boost/system.hpp>
|
||||
|
||||
This convenience header includes all the headers previously described.
|
||||
|
@ -9,10 +9,6 @@
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if (__cplusplus >= 201103L) && !(defined(BOOST_GCC) && BOOST_GCC < 40800) || (defined(_MSC_VER) && _MSC_VER >= 1900)
|
||||
# include <boost/system/result.hpp>
|
||||
#endif
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_HPP_INCLUDED
|
||||
|
@ -1,63 +0,0 @@
|
||||
// boost/system/cygwin_error.hpp -------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2007
|
||||
|
||||
// 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
|
||||
|
||||
#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.
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( errno, system_category() )
|
||||
|
||||
// User code should use the portable "posix" enums for POSIX errors; this
|
||||
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
||||
// errno values that POSIX-based systems typically provide in addition to
|
||||
// POSIX values, use the system specific enums below.
|
||||
|
||||
namespace cygwin_error
|
||||
{
|
||||
enum cygwin_errno
|
||||
{
|
||||
no_net = ENONET,
|
||||
no_package = ENOPKG,
|
||||
no_share = ENOSHARE
|
||||
};
|
||||
} // namespace cygwin_error
|
||||
|
||||
template<> struct is_error_code_enum<cygwin_error::cygwin_errno>
|
||||
{ static const bool value = true; };
|
||||
|
||||
namespace cygwin_error
|
||||
{
|
||||
inline error_code make_error_code( cygwin_errno e )
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __CYGWIN__
|
||||
|
||||
#endif // BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
@ -8,26 +8,19 @@
|
||||
//
|
||||
// See http://www.boost.org/libs/system for documentation.
|
||||
|
||||
#include <boost/system/detail/requires_cxx11.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
// BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
//
|
||||
// The macro BOOST_SYSTEM_DISABLE_THREADS can be defined on configurations
|
||||
// that provide <system_error> and <atomic>, but not <mutex>, such as the
|
||||
// single-threaded libstdc++.
|
||||
//
|
||||
// https://github.com/boostorg/system/issues/92
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC) && ( !defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_SYSTEM_DISABLE_THREADS) )
|
||||
# define BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
#endif
|
||||
|
||||
// BOOST_SYSTEM_NOEXCEPT
|
||||
// Retained for backward compatibility
|
||||
|
||||
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
|
||||
#define BOOST_SYSTEM_NOEXCEPT noexcept
|
||||
|
||||
// BOOST_SYSTEM_HAS_CONSTEXPR
|
||||
|
||||
|
@ -5,28 +5,19 @@
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<bool C, class T = void> struct enable_if
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T> struct enable_if<false, T>
|
||||
{
|
||||
};
|
||||
using std::enable_if;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
|
||||
|
@ -17,11 +17,8 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <cstddef>
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <system_error>
|
||||
# include <atomic>
|
||||
#endif
|
||||
#include <system_error>
|
||||
#include <atomic>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -64,20 +61,11 @@ private:
|
||||
friend class error_code;
|
||||
friend class error_condition;
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
|
||||
public:
|
||||
|
||||
error_category( error_category const & ) = delete;
|
||||
error_category& operator=( error_category const & ) = delete;
|
||||
|
||||
#else
|
||||
private:
|
||||
|
||||
error_category( error_category const & );
|
||||
error_category& operator=( error_category const & );
|
||||
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
boost::ulong_long_type id_;
|
||||
@ -90,75 +78,47 @@ private:
|
||||
void const* stdcat_align_;
|
||||
};
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
mutable std::atomic< unsigned > sc_init_;
|
||||
|
||||
#else
|
||||
|
||||
unsigned sc_init_;
|
||||
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
|
||||
|
||||
~error_category() = default;
|
||||
|
||||
#else
|
||||
|
||||
// We'd like to make the destructor protected, to make code that deletes
|
||||
// an error_category* not compile; unfortunately, doing the below makes
|
||||
// the destructor user-provided and hence breaks use after main, as the
|
||||
// categories may get destroyed before code that uses them
|
||||
|
||||
// ~error_category() {}
|
||||
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
error_category() BOOST_NOEXCEPT: id_( 0 ), stdcat_(), sc_init_()
|
||||
constexpr error_category() noexcept: id_( 0 ), stdcat_(), sc_init_()
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id ), stdcat_(), sc_init_()
|
||||
explicit constexpr error_category( boost::ulong_long_type id ) noexcept: id_( id ), stdcat_(), sc_init_()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT = 0;
|
||||
virtual const char * name() const noexcept = 0;
|
||||
|
||||
virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
|
||||
virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT;
|
||||
virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
|
||||
virtual error_condition default_error_condition( int ev ) const noexcept;
|
||||
virtual bool equivalent( int code, const error_condition & condition ) const noexcept;
|
||||
virtual bool equivalent( const error_code & code, int condition ) const noexcept;
|
||||
|
||||
virtual std::string message( int ev ) const = 0;
|
||||
virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
|
||||
virtual char const * message( int ev, char * buffer, std::size_t len ) const noexcept;
|
||||
|
||||
virtual bool failed( int ev ) const BOOST_NOEXCEPT
|
||||
virtual bool failed( int ev ) const noexcept
|
||||
{
|
||||
return ev != 0;
|
||||
}
|
||||
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) noexcept
|
||||
{
|
||||
return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_;
|
||||
}
|
||||
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) BOOST_NOEXCEPT
|
||||
friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) noexcept
|
||||
{
|
||||
if( lhs.id_ < rhs.id_ )
|
||||
{
|
||||
@ -178,8 +138,6 @@ public:
|
||||
return std::less<error_category const *>()( &lhs, &rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
void init_stdcat() const;
|
||||
|
||||
# if defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
@ -187,8 +145,6 @@ public:
|
||||
# else
|
||||
operator std::error_category const & () const BOOST_SYMBOL_VISIBLE;
|
||||
# endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
|
||||
|
@ -26,22 +26,22 @@ namespace system
|
||||
|
||||
// error_category default implementation
|
||||
|
||||
inline error_condition error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
inline error_condition error_category::default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
return error_condition( ev, *this );
|
||||
}
|
||||
|
||||
inline bool error_category::equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT
|
||||
inline bool error_category::equivalent( int code, const error_condition & condition ) const noexcept
|
||||
{
|
||||
return default_error_condition( code ) == condition;
|
||||
}
|
||||
|
||||
inline bool error_category::equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT
|
||||
inline bool error_category::equivalent( const error_code & code, int condition ) const noexcept
|
||||
{
|
||||
return code.equals( condition, *this );
|
||||
}
|
||||
|
||||
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
if( len == 0 )
|
||||
{
|
||||
@ -58,27 +58,7 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
try
|
||||
#endif
|
||||
{
|
||||
std::string m = this->message( ev );
|
||||
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4996 )
|
||||
# elif defined(__clang__) && defined(__has_warning)
|
||||
# pragma clang diagnostic push
|
||||
# if __has_warning("-Wdeprecated-declarations")
|
||||
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
std::strncpy( buffer, m.c_str(), len - 1 );
|
||||
buffer[ len-1 ] = 0;
|
||||
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( pop )
|
||||
# elif defined(__clang__) && defined(__has_warning)
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
|
||||
detail::snprintf( buffer, len, "%s", this->message( ev ).c_str() );
|
||||
return buffer;
|
||||
}
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
@ -95,8 +75,6 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
|
||||
// interoperability with std::error_code, std::error_condition
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
#include <boost/system/detail/std_category_impl.hpp>
|
||||
#include <boost/system/detail/mutex.hpp>
|
||||
#include <new>
|
||||
@ -185,6 +163,4 @@ inline BOOST_NOINLINE error_category::operator std::error_category const & () co
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
|
||||
|
@ -21,11 +21,7 @@
|
||||
#include <boost/system/detail/append_int.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <boost/system/detail/std_category.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/system/detail/std_category.hpp>
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@ -33,10 +29,7 @@
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <system_error>
|
||||
#endif
|
||||
#include <system_error>
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
|
||||
# pragma GCC diagnostic push
|
||||
@ -58,14 +51,14 @@ namespace system
|
||||
// and error_code containing a pointer to an object of a type derived
|
||||
// from error_category.
|
||||
|
||||
bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT;
|
||||
bool operator==( const error_code & code, const error_condition & condition ) noexcept;
|
||||
std::size_t hash_value( error_code const & ec );
|
||||
|
||||
class error_code
|
||||
{
|
||||
private:
|
||||
|
||||
friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT;
|
||||
friend bool operator==( const error_code & code, const error_condition & condition ) noexcept;
|
||||
friend std::size_t hash_value( error_code const & ec );
|
||||
|
||||
private:
|
||||
@ -79,9 +72,7 @@ private:
|
||||
union
|
||||
{
|
||||
data d1_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
unsigned char d2_[ sizeof(std::error_code) ];
|
||||
#endif
|
||||
};
|
||||
|
||||
// 0: default constructed, d1_ value initialized
|
||||
@ -93,7 +84,7 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
char const* category_name() const BOOST_NOEXCEPT
|
||||
char const* category_name() const noexcept
|
||||
{
|
||||
// return category().name();
|
||||
|
||||
@ -117,22 +108,19 @@ public:
|
||||
|
||||
// constructors:
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
error_code() BOOST_NOEXCEPT:
|
||||
constexpr error_code() noexcept:
|
||||
d1_(), lc_flags_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) noexcept:
|
||||
d1_(), lc_flags_( 2 + detail::failed_impl( val, cat ) )
|
||||
{
|
||||
d1_.val_ = val;
|
||||
d1_.cat_ = &cat;
|
||||
}
|
||||
|
||||
error_code( int val, const error_category & cat, source_location const * loc ) BOOST_NOEXCEPT:
|
||||
error_code( int val, const error_category & cat, source_location const * loc ) noexcept:
|
||||
d1_(), lc_flags_( ( loc? reinterpret_cast<boost::uintptr_t>( loc ): 2 ) | +detail::failed_impl( val, cat ) )
|
||||
{
|
||||
d1_.val_ = val;
|
||||
@ -142,15 +130,13 @@ public:
|
||||
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
||||
typename detail::enable_if<
|
||||
is_error_code_enum<ErrorCodeEnum>::value
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|| std::is_error_code_enum<ErrorCodeEnum>::value
|
||||
#endif
|
||||
>::type* = 0 ) BOOST_NOEXCEPT: d1_(), lc_flags_( 0 )
|
||||
>::type* = 0 ) noexcept: d1_(), lc_flags_( 0 )
|
||||
{
|
||||
*this = make_error_code( e );
|
||||
}
|
||||
|
||||
error_code( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT:
|
||||
error_code( error_code const& ec, source_location const * loc ) noexcept:
|
||||
d1_(), lc_flags_( 0 )
|
||||
{
|
||||
*this = ec;
|
||||
@ -161,9 +147,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
error_code( std::error_code const& ec ) BOOST_NOEXCEPT:
|
||||
error_code( std::error_code const& ec ) noexcept:
|
||||
d1_(), lc_flags_( 0 )
|
||||
{
|
||||
#ifndef BOOST_NO_RTTI
|
||||
@ -181,41 +165,39 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// modifiers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) noexcept
|
||||
{
|
||||
*this = error_code( val, cat );
|
||||
}
|
||||
|
||||
void assign( int val, const error_category & cat, source_location const * loc ) BOOST_NOEXCEPT
|
||||
void assign( int val, const error_category & cat, source_location const * loc ) noexcept
|
||||
{
|
||||
*this = error_code( val, cat, loc );
|
||||
}
|
||||
|
||||
void assign( error_code const& ec, source_location const * loc ) BOOST_NOEXCEPT
|
||||
void assign( error_code const& ec, source_location const * loc ) noexcept
|
||||
{
|
||||
*this = error_code( ec, loc );
|
||||
}
|
||||
|
||||
template<typename ErrorCodeEnum>
|
||||
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
|
||||
operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT
|
||||
operator=( ErrorCodeEnum val ) noexcept
|
||||
{
|
||||
*this = make_error_code( val );
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() noexcept
|
||||
{
|
||||
*this = error_code();
|
||||
}
|
||||
|
||||
// observers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const noexcept
|
||||
{
|
||||
if( lc_flags_ != 1 )
|
||||
{
|
||||
@ -223,22 +205,16 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
|
||||
unsigned cv = static_cast<unsigned>( ec.value() );
|
||||
unsigned ch = static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
||||
|
||||
return static_cast<int>( cv + 1000 * ch );
|
||||
#else
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const noexcept
|
||||
{
|
||||
if( lc_flags_ == 0 )
|
||||
{
|
||||
@ -255,24 +231,19 @@ public:
|
||||
}
|
||||
|
||||
// deprecated?
|
||||
error_condition default_error_condition() const BOOST_NOEXCEPT
|
||||
error_condition default_error_condition() const noexcept
|
||||
{
|
||||
return category().default_error_condition( value() );
|
||||
}
|
||||
|
||||
std::string message() const
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lc_flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.message();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if( lc_flags_ == 0 )
|
||||
else if( lc_flags_ == 0 )
|
||||
{
|
||||
return detail::system_error_category_message( value() );
|
||||
}
|
||||
@ -282,9 +253,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
if( lc_flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
@ -304,9 +274,7 @@ public:
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if( lc_flags_ == 0 )
|
||||
else if( lc_flags_ == 0 )
|
||||
{
|
||||
return detail::system_error_category_message( value(), buffer, len );
|
||||
}
|
||||
@ -316,17 +284,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const noexcept
|
||||
{
|
||||
if( lc_flags_ & 1 )
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
if( lc_flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.value() != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -335,36 +302,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const noexcept // true if error
|
||||
{
|
||||
return failed();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
typedef void (*unspecified_bool_type)();
|
||||
static void unspecified_bool_true() {}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool has_location() const BOOST_NOEXCEPT
|
||||
bool has_location() const noexcept
|
||||
{
|
||||
return lc_flags_ >= 4;
|
||||
}
|
||||
|
||||
source_location const & location() const BOOST_NOEXCEPT
|
||||
source_location const & location() const noexcept
|
||||
{
|
||||
BOOST_STATIC_CONSTEXPR source_location loc;
|
||||
return lc_flags_ >= 4? *reinterpret_cast<source_location const*>( lc_flags_ &~ static_cast<boost::uintptr_t>( 1 ) ): loc;
|
||||
@ -378,7 +326,7 @@ private:
|
||||
|
||||
friend class error_category;
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool equals( int val, error_category const& cat ) const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR bool equals( int val, error_category const& cat ) const noexcept
|
||||
{
|
||||
if( lc_flags_ == 0 )
|
||||
{
|
||||
@ -399,10 +347,8 @@ public:
|
||||
// the more symmetrical non-member syntax allows enum
|
||||
// conversions work for both rhs and lhs.
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) noexcept
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
@ -416,16 +362,13 @@ public:
|
||||
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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) noexcept
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
@ -440,35 +383,32 @@ public:
|
||||
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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) noexcept
|
||||
{
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( error_code const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( error_code const & lhs, std::error_code const & rhs ) noexcept
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_code const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_code const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
@ -476,25 +416,25 @@ public:
|
||||
//
|
||||
|
||||
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
|
||||
inline friend bool operator==( error_code const & lhs, E rhs ) 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
|
||||
inline friend bool operator==( E lhs, error_code const & rhs ) 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
|
||||
inline friend bool operator!=( error_code const & lhs, E rhs ) 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
|
||||
inline friend bool operator!=( E lhs, error_code const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
@ -502,47 +442,47 @@ public:
|
||||
//
|
||||
|
||||
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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_code const & lhs, E rhs ) 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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_code const & rhs ) 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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_code const & lhs, E rhs ) 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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_code const & rhs ) 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
|
||||
inline friend bool operator==( error_code const & lhs, std::error_condition const & rhs ) noexcept
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator==( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( std::error_condition const & lhs, error_code const & rhs ) noexcept
|
||||
{
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_condition const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( std::error_condition const & lhs, error_code const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
@ -601,14 +541,10 @@ public:
|
||||
class E = typename std::enable_if<std::is_same<T, std::error_code>::value>::type>
|
||||
operator T const& () = delete;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lc_flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
@ -620,7 +556,6 @@ public:
|
||||
return r;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
std::string r = category_name();
|
||||
detail::append_int( r, value() );
|
||||
@ -653,49 +588,41 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
inline bool operator==( const error_code & code, const error_condition & condition ) noexcept
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.lc_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 bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
inline bool operator==( const error_condition & condition, const error_code & code ) noexcept
|
||||
{
|
||||
return code == condition;
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline std::size_t hash_value( error_code const & ec )
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( ec.lc_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_;
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
boost::ulong_long_type cat_id() const BOOST_NOEXCEPT
|
||||
boost::ulong_long_type cat_id() const noexcept
|
||||
{
|
||||
return cat_? cat_->id_: detail::generic_category_id;
|
||||
}
|
||||
@ -59,17 +59,17 @@ public:
|
||||
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() noexcept:
|
||||
val_( 0 ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) noexcept:
|
||||
val_( val ), cat_( &cat )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit error_condition( boost::system::detail::generic_value_tag vt ) BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR explicit error_condition( boost::system::detail::generic_value_tag vt ) noexcept:
|
||||
val_( vt.value ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
@ -77,20 +77,20 @@ public:
|
||||
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
|
||||
typename detail::enable_if<
|
||||
is_error_condition_enum<ErrorConditionEnum>::value && !boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value
|
||||
>::type* = 0) BOOST_NOEXCEPT
|
||||
>::type* = 0) 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:
|
||||
typename detail::enable_if<boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value>::type* = 0) noexcept:
|
||||
val_( e ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
// modifiers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) noexcept
|
||||
{
|
||||
val_ = val;
|
||||
cat_ = &cat;
|
||||
@ -98,13 +98,13 @@ public:
|
||||
|
||||
template<typename ErrorConditionEnum>
|
||||
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
|
||||
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
|
||||
operator=( ErrorConditionEnum val ) noexcept
|
||||
{
|
||||
*this = error_condition( val );
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() noexcept
|
||||
{
|
||||
val_ = 0;
|
||||
cat_ = 0;
|
||||
@ -112,12 +112,12 @@ public:
|
||||
|
||||
// observers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const noexcept
|
||||
{
|
||||
return val_;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const noexcept
|
||||
{
|
||||
return cat_? *cat_: generic_category();
|
||||
}
|
||||
@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
if( cat_ )
|
||||
{
|
||||
@ -146,7 +146,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const noexcept
|
||||
{
|
||||
if( cat_ )
|
||||
{
|
||||
@ -158,35 +158,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const noexcept // true if error
|
||||
{
|
||||
return failed();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
typedef void (*unspecified_bool_type)();
|
||||
static void unspecified_bool_true() {}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// relationals:
|
||||
// the more symmetrical non-member syntax allows enum
|
||||
// conversions work for both rhs and lhs.
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept
|
||||
{
|
||||
if( lhs.val_ != rhs.val_ )
|
||||
{
|
||||
@ -206,20 +187,18 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept
|
||||
{
|
||||
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
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
operator std::error_condition () const
|
||||
{
|
||||
// This condition must be the same as the one in error_category_impl.hpp
|
||||
@ -241,22 +220,22 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) noexcept
|
||||
{
|
||||
return lhs == static_cast< std::error_condition >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( error_condition const & lhs, std::error_code const & rhs ) noexcept
|
||||
{
|
||||
return static_cast< std::error_condition >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_condition const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( error_condition const & lhs, std::error_code const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
@ -264,25 +243,25 @@ public:
|
||||
//
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_condition const & lhs, E rhs ) noexcept
|
||||
{
|
||||
return lhs == make_error_condition( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_condition const & rhs ) noexcept
|
||||
{
|
||||
return make_error_condition( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_condition const & lhs, E rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_condition const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
@ -290,31 +269,29 @@ public:
|
||||
//
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator==( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( error_condition const & lhs, E rhs ) 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>
|
||||
inline friend bool operator==( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator==( E lhs, error_condition const & rhs ) 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>
|
||||
inline friend bool operator!=( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( error_condition const & lhs, E rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator!=( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
inline friend bool operator!=( E lhs, error_condition const & rhs ) noexcept
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::string to_string() const
|
||||
{
|
||||
std::string r( "cond:" );
|
||||
|
@ -35,18 +35,18 @@ class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR generic_error_category() noexcept:
|
||||
error_category( detail::generic_category_id )
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
const char * name() const noexcept BOOST_OVERRIDE
|
||||
{
|
||||
return "generic";
|
||||
}
|
||||
|
||||
std::string message( int ev ) const BOOST_OVERRIDE;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const noexcept BOOST_OVERRIDE;
|
||||
};
|
||||
|
||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||
@ -55,7 +55,7 @@ public:
|
||||
|
||||
// generic_error_category::message
|
||||
|
||||
inline char const * generic_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
inline char const * generic_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
return generic_error_category_message( ev, buffer, len );
|
||||
}
|
||||
@ -86,7 +86,7 @@ template<class T> constexpr generic_error_category generic_cat_holder<T>::instan
|
||||
|
||||
} // namespace detail
|
||||
|
||||
constexpr error_category const & generic_category() BOOST_NOEXCEPT
|
||||
constexpr error_category const & generic_category() noexcept
|
||||
{
|
||||
return detail::generic_cat_holder<void>::instance;
|
||||
}
|
||||
@ -94,10 +94,10 @@ constexpr error_category const & generic_category() BOOST_NOEXCEPT
|
||||
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
inline error_category const & generic_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||
inline error_category const & generic_category() noexcept BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
inline error_category const & generic_category() BOOST_NOEXCEPT
|
||||
inline error_category const & generic_category() noexcept
|
||||
{
|
||||
static const detail::generic_error_category instance;
|
||||
return instance;
|
||||
|
@ -27,19 +27,31 @@ namespace detail
|
||||
|
||||
// glibc has two incompatible strerror_r definitions
|
||||
|
||||
inline char const * strerror_r_helper( char const * r, char const * ) BOOST_NOEXCEPT
|
||||
inline char const * strerror_r_helper( char const * r, char const * ) noexcept
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
inline char const * strerror_r_helper( int r, char const * buffer ) BOOST_NOEXCEPT
|
||||
inline char const * strerror_r_helper( int r, char const * buffer ) noexcept
|
||||
{
|
||||
return r == 0? buffer: "Unknown error";
|
||||
}
|
||||
|
||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
|
||||
{
|
||||
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
|
||||
if( buffer != nullptr )
|
||||
{
|
||||
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
// strerror_r requires non-null buffer pointer
|
||||
|
||||
char tmp[ 1 ] = {};
|
||||
char const* r = strerror_r_helper( strerror_r( ev, tmp, 0 ), buffer );
|
||||
|
||||
return r == tmp? nullptr: r;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string generic_error_category_message( int ev )
|
||||
@ -68,7 +80,7 @@ inline std::string generic_error_category_message( int ev )
|
||||
return m? m: "Unknown error";
|
||||
}
|
||||
|
||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
|
||||
{
|
||||
if( len == 0 )
|
||||
{
|
||||
|
@ -35,25 +35,25 @@ class BOOST_SYMBOL_VISIBLE interop_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR interop_error_category() BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR interop_error_category() noexcept:
|
||||
error_category( detail::interop_category_id )
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
const char * name() const 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;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const 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
|
||||
inline char const * interop_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
detail::snprintf( buffer, len, "Unknown interop error %d", ev );
|
||||
return buffer;
|
||||
@ -79,7 +79,7 @@ template<class T> struct BOOST_SYMBOL_VISIBLE interop_cat_holder
|
||||
template<class T> constexpr interop_error_category interop_cat_holder<T>::instance;
|
||||
#endif
|
||||
|
||||
constexpr error_category const & interop_category() BOOST_NOEXCEPT
|
||||
constexpr error_category const & interop_category() noexcept
|
||||
{
|
||||
return interop_cat_holder<void>::instance;
|
||||
}
|
||||
@ -87,10 +87,10 @@ constexpr error_category const & interop_category() BOOST_NOEXCEPT
|
||||
#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;
|
||||
inline error_category const & interop_category() noexcept BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
inline error_category const & interop_category() BOOST_NOEXCEPT
|
||||
inline error_category const & interop_category() noexcept
|
||||
{
|
||||
static const detail::interop_error_category instance;
|
||||
return instance;
|
||||
|
@ -5,29 +5,19 @@
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
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 };
|
||||
};
|
||||
using std::is_same;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
|
||||
|
@ -40,13 +40,20 @@ struct mutex
|
||||
// issues. However, shared_mutex is based on SRWLock and its
|
||||
// default constructor is constexpr, so we use that instead.
|
||||
|
||||
#include <boost/winapi/config.hpp>
|
||||
|
||||
// SRWLOCK is not available when targeting Windows XP
|
||||
#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
|
||||
#include <shared_mutex>
|
||||
|
||||
#if BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
|
||||
# define BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
|
||||
|
||||
#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || \
|
||||
defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.System 1.82 and will be removed in Boost.System 1.84. Please open an issue in https://github.com/boostorg/system if you want it retained.")
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
@ -8,66 +8,21 @@
|
||||
//
|
||||
// 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
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
__attribute__((__format__ (__printf__, 3, 4)))
|
||||
#endif
|
||||
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
|
||||
using std::snprintf;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||
|
@ -35,7 +35,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
boost::system::error_category const & original_category() const BOOST_NOEXCEPT
|
||||
boost::system::error_category const & original_category() const noexcept
|
||||
{
|
||||
return *pc_;
|
||||
}
|
||||
@ -51,16 +51,12 @@ public:
|
||||
// here when Id != 0, but this should never happen now because this code
|
||||
// path is no longer used
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
|
||||
|
||||
static_assert( Id == 0, "This constructor should only be called with Id == 0 under MS STL 14.0+" );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
const char * name() const noexcept BOOST_OVERRIDE
|
||||
{
|
||||
return pc_->name();
|
||||
}
|
||||
@ -70,13 +66,13 @@ public:
|
||||
return pc_->message( ev );
|
||||
}
|
||||
|
||||
std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
std::error_condition default_error_condition( int ev ) const noexcept BOOST_OVERRIDE
|
||||
{
|
||||
return pc_->default_error_condition( ev );
|
||||
}
|
||||
|
||||
inline bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
inline bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
inline bool equivalent( int code, const std::error_condition & condition ) const noexcept BOOST_OVERRIDE;
|
||||
inline bool equivalent( const std::error_code & code, int condition ) const noexcept BOOST_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@ -26,7 +26,7 @@ namespace system
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT
|
||||
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const noexcept
|
||||
{
|
||||
if( condition.category() == *this )
|
||||
{
|
||||
@ -55,7 +55,7 @@ inline bool std_category::equivalent( int code, const std::error_condition & con
|
||||
}
|
||||
}
|
||||
|
||||
inline bool std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT
|
||||
inline bool std_category::equivalent( const std::error_code & code, int condition ) const noexcept
|
||||
{
|
||||
if( code.category() == *this )
|
||||
{
|
||||
|
@ -34,20 +34,20 @@ class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
|
||||
{
|
||||
public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
|
||||
BOOST_SYSTEM_CONSTEXPR system_error_category() noexcept:
|
||||
error_category( detail::system_category_id )
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
const char * name() const noexcept BOOST_OVERRIDE
|
||||
{
|
||||
return "system";
|
||||
}
|
||||
|
||||
error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
error_condition default_error_condition( int ev ) const noexcept BOOST_OVERRIDE;
|
||||
|
||||
std::string message( int ev ) const BOOST_OVERRIDE;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
|
||||
char const * message( int ev, char * buffer, std::size_t len ) const noexcept BOOST_OVERRIDE;
|
||||
};
|
||||
|
||||
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
|
||||
@ -75,7 +75,7 @@ template<class T> constexpr system_error_category system_cat_holder<T>::instance
|
||||
|
||||
} // namespace detail
|
||||
|
||||
constexpr error_category const & system_category() BOOST_NOEXCEPT
|
||||
constexpr error_category const & system_category() noexcept
|
||||
{
|
||||
return detail::system_cat_holder<void>::instance;
|
||||
}
|
||||
@ -83,10 +83,10 @@ constexpr error_category const & system_category() BOOST_NOEXCEPT
|
||||
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
#if !defined(__SUNPRO_CC) // trailing __global is not supported
|
||||
inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||
inline error_category const & system_category() noexcept BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
inline error_category const & system_category() BOOST_NOEXCEPT
|
||||
inline error_category const & system_category() noexcept
|
||||
{
|
||||
static const detail::system_error_category instance;
|
||||
return instance;
|
||||
|
@ -25,7 +25,7 @@ namespace system
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
inline int system_category_condition_win32( int ev ) noexcept
|
||||
{
|
||||
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
||||
// We want to map the common Win32 errors to their equivalent error condition,
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <boost/system/detail/system_category_condition_win32.hpp>
|
||||
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
int e2 = system_category_condition_win32( ev );
|
||||
|
||||
@ -41,7 +41,7 @@ inline boost::system::error_condition boost::system::detail::system_error_catego
|
||||
|
||||
#else // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
return error_condition( boost::system::detail::generic_value_tag( ev ) );
|
||||
}
|
||||
@ -53,7 +53,7 @@ inline std::string boost::system::detail::system_error_category::message( int ev
|
||||
return system_error_category_message( ev );
|
||||
}
|
||||
|
||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
|
||||
{
|
||||
return system_error_category_message( ev, buffer, len );
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ inline std::string system_error_category_message( int ev )
|
||||
return system_category_message_win32( ev );
|
||||
}
|
||||
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
|
||||
{
|
||||
return system_category_message_win32( ev, buffer, len );
|
||||
}
|
||||
@ -57,7 +57,7 @@ inline std::string system_error_category_message( int ev )
|
||||
return generic_error_category_message( ev );
|
||||
}
|
||||
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
|
||||
{
|
||||
return generic_error_category_message( ev, buffer, len );
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ inline boost::winapi::UINT_ message_cp_win32()
|
||||
#endif
|
||||
}
|
||||
|
||||
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) noexcept
|
||||
{
|
||||
if( len == 0 )
|
||||
{
|
||||
@ -73,7 +73,7 @@ inline char const * system_category_message_win32( int ev, char * buffer, std::s
|
||||
DWORD_ retval = boost::winapi::FormatMessageA(
|
||||
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||
NULL,
|
||||
ev,
|
||||
static_cast<DWORD_>(ev),
|
||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||
buffer,
|
||||
static_cast<DWORD_>( len ),
|
||||
@ -94,7 +94,7 @@ inline char const * system_category_message_win32( int ev, char * buffer, std::s
|
||||
DWORD_ retval = boost::winapi::FormatMessageW(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||
NULL,
|
||||
ev,
|
||||
static_cast<DWORD_>(ev),
|
||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||
(LPWSTR_) &lpMsgBuf,
|
||||
0,
|
||||
@ -152,7 +152,7 @@ inline std::string system_category_message_win32( int ev )
|
||||
DWORD_ retval = boost::winapi::FormatMessageW(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
|
||||
NULL,
|
||||
ev,
|
||||
static_cast<DWORD_>(ev),
|
||||
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
|
||||
(LPWSTR_) &lpMsgBuf,
|
||||
0,
|
||||
@ -176,7 +176,7 @@ inline std::string system_category_message_win32( int ev )
|
||||
return unknown_message_win32( ev );
|
||||
}
|
||||
|
||||
std::string buffer( r, char() );
|
||||
std::string buffer( static_cast<std::size_t>(r), char() );
|
||||
|
||||
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, &buffer[0], r, NULL, NULL );
|
||||
|
||||
@ -187,12 +187,12 @@ inline std::string system_category_message_win32( int ev )
|
||||
|
||||
--r; // exclude null terminator
|
||||
|
||||
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
|
||||
while( r > 0 && ( buffer[ static_cast<std::size_t>(r)-1 ] == '\n' || buffer[ static_cast<std::size_t>(r)-1 ] == '\r' ) )
|
||||
{
|
||||
--r;
|
||||
}
|
||||
|
||||
if( r > 0 && buffer[ r-1 ] == '.' )
|
||||
if( r > 0 && buffer[ static_cast<std::size_t>(r)-1 ] == '.' )
|
||||
{
|
||||
--r;
|
||||
}
|
||||
|
@ -31,19 +31,19 @@ namespace errc
|
||||
{
|
||||
|
||||
// explicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) noexcept
|
||||
{
|
||||
return error_code( e, generic_category() );
|
||||
}
|
||||
|
||||
// explicit conversion:
|
||||
inline error_code make_error_code( errc_t e, boost::source_location const * loc ) BOOST_NOEXCEPT
|
||||
inline error_code make_error_code( errc_t e, boost::source_location const * loc ) noexcept
|
||||
{
|
||||
return error_code( e, generic_category(), loc );
|
||||
}
|
||||
|
||||
// implicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) noexcept
|
||||
{
|
||||
return error_condition( e, generic_category() );
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ BOOST_NORETURN BOOST_NOINLINE inline void throw_exception_from_error( std::excep
|
||||
// in_place_*
|
||||
|
||||
using in_place_value_t = variant2::in_place_index_t<0>;
|
||||
constexpr in_place_value_t in_place_value{};
|
||||
BOOST_INLINE_CONSTEXPR in_place_value_t in_place_value{};
|
||||
|
||||
using in_place_error_t = variant2::in_place_index_t<1>;
|
||||
constexpr in_place_error_t in_place_error{};
|
||||
BOOST_INLINE_CONSTEXPR in_place_error_t in_place_error{};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@ -332,40 +332,28 @@ public:
|
||||
|
||||
BOOST_CXX14_CONSTEXPR T& operator*() noexcept
|
||||
{
|
||||
T* p = operator->();
|
||||
|
||||
BOOST_ASSERT( p != 0 );
|
||||
|
||||
return *p;
|
||||
BOOST_ASSERT( has_value() );
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR T const& operator*() const noexcept
|
||||
{
|
||||
T const* p = operator->();
|
||||
|
||||
BOOST_ASSERT( p != 0 );
|
||||
|
||||
return *p;
|
||||
BOOST_ASSERT( has_value() );
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
BOOST_CXX14_CONSTEXPR T& operator*() & noexcept
|
||||
{
|
||||
T* p = operator->();
|
||||
|
||||
BOOST_ASSERT( p != 0 );
|
||||
|
||||
return *p;
|
||||
BOOST_ASSERT( has_value() );
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR T const& operator*() const & noexcept
|
||||
{
|
||||
T const* p = operator->();
|
||||
|
||||
BOOST_ASSERT( p != 0 );
|
||||
|
||||
return *p;
|
||||
BOOST_ASSERT( has_value() );
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
template<class U = T>
|
||||
@ -450,6 +438,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
|
||||
template<class T, class E> constexpr in_place_value_t result<T, E>::in_place_value;
|
||||
template<class T, class E> constexpr in_place_error_t result<T, E>::in_place_error;
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr, class T, class E> std::basic_ostream<Ch, Tr>& operator<<( std::basic_ostream<Ch, Tr>& os, result<T, E> const & r )
|
||||
{
|
||||
if( r.has_value() )
|
||||
@ -538,6 +533,23 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// converting
|
||||
template<class E2, class En = typename std::enable_if<
|
||||
std::is_convertible<E2, E>::value
|
||||
>::type>
|
||||
BOOST_CXX14_CONSTEXPR result( result<void, E2> const& r2 )
|
||||
noexcept(
|
||||
std::is_nothrow_constructible<E, E2>::value &&
|
||||
std::is_nothrow_default_constructible<E2>::value &&
|
||||
std::is_nothrow_copy_constructible<E2>::value )
|
||||
: v_( in_place_error, r2.error() )
|
||||
{
|
||||
if( r2 )
|
||||
{
|
||||
this->emplace();
|
||||
}
|
||||
}
|
||||
|
||||
// queries
|
||||
|
||||
constexpr bool has_value() const noexcept
|
||||
@ -635,6 +647,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
|
||||
template<class E> constexpr in_place_value_t result<void, E>::in_place_value;
|
||||
template<class E> constexpr in_place_error_t result<void, E>::in_place_error;
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr, class E> std::basic_ostream<Ch, Tr>& operator<<( std::basic_ostream<Ch, Tr>& os, result<void, E> const & r )
|
||||
{
|
||||
if( r.has_value() )
|
||||
@ -649,6 +668,667 @@ template<class Ch, class Tr, class E> std::basic_ostream<Ch, Tr>& operator<<( st
|
||||
return os;
|
||||
}
|
||||
|
||||
// result<T&, E>
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class U, class A> struct reference_to_temporary: std::integral_constant<bool,
|
||||
!std::is_reference<A>::value ||
|
||||
!std::is_convertible<typename std::remove_reference<A>::type*, U*>::value
|
||||
> {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class U, class E> class result<U&, E>
|
||||
{
|
||||
private:
|
||||
|
||||
variant2::variant<U*, E> v_;
|
||||
|
||||
public:
|
||||
|
||||
using value_type = U&;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
|
||||
// implicit, value
|
||||
template<class A, typename std::enable_if<
|
||||
std::is_convertible<A, U&>::value &&
|
||||
!detail::reference_to_temporary<U, A>::value &&
|
||||
!std::is_convertible<A, E>::value, int>::type = 0>
|
||||
constexpr result( A&& a )
|
||||
noexcept( std::is_nothrow_constructible<U&, A>::value )
|
||||
: v_( in_place_value, &static_cast<U&>( std::forward<A>(a) ) )
|
||||
{
|
||||
}
|
||||
|
||||
// implicit, error
|
||||
template<class A = E, class = void, typename std::enable_if<
|
||||
std::is_convertible<A, E>::value &&
|
||||
!std::is_convertible<A, U&>::value, int>::type = 0>
|
||||
constexpr result( A&& a )
|
||||
noexcept( std::is_nothrow_constructible<E, A>::value )
|
||||
: v_( in_place_error, std::forward<A>(a) )
|
||||
{
|
||||
}
|
||||
|
||||
// explicit, value
|
||||
template<class A, class En = typename std::enable_if<
|
||||
detail::is_constructible<U&, A>::value &&
|
||||
!std::is_convertible<A, U&>::value &&
|
||||
!detail::reference_to_temporary<U, A>::value &&
|
||||
!detail::is_constructible<E, A>::value
|
||||
>::type>
|
||||
explicit constexpr result( A&& a )
|
||||
noexcept( std::is_nothrow_constructible<U&, A>::value )
|
||||
: v_( in_place_value, &static_cast<U&>( std::forward<A>(a) ) )
|
||||
{
|
||||
}
|
||||
|
||||
// explicit, error
|
||||
template<class... A, class En2 = void, class En = typename std::enable_if<
|
||||
!detail::is_constructible<U&, A...>::value &&
|
||||
detail::is_constructible<E, A...>::value &&
|
||||
sizeof...(A) >= 1
|
||||
>::type>
|
||||
explicit constexpr result( A&&... a )
|
||||
noexcept( std::is_nothrow_constructible<E, A...>::value )
|
||||
: v_( in_place_error, std::forward<A>(a)... )
|
||||
{
|
||||
}
|
||||
|
||||
// tagged, value
|
||||
template<class A, class En = typename std::enable_if<
|
||||
std::is_constructible<U&, A>::value &&
|
||||
!detail::reference_to_temporary<U, A>::value
|
||||
>::type>
|
||||
constexpr result( in_place_value_t, A&& a )
|
||||
noexcept( std::is_nothrow_constructible<U&, A>::value )
|
||||
: v_( in_place_value, &static_cast<U&>( std::forward<A>(a) ) )
|
||||
{
|
||||
}
|
||||
|
||||
// tagged, error
|
||||
template<class... A, class En = typename std::enable_if<
|
||||
std::is_constructible<E, A...>::value
|
||||
>::type>
|
||||
constexpr result( in_place_error_t, A&&... a )
|
||||
noexcept( std::is_nothrow_constructible<E, A...>::value )
|
||||
: v_( in_place_error, std::forward<A>(a)... )
|
||||
{
|
||||
}
|
||||
|
||||
// converting
|
||||
template<class U2, class E2, class En = typename std::enable_if<
|
||||
std::is_convertible<U2&, U&>::value &&
|
||||
!detail::reference_to_temporary<U, U2&>::value &&
|
||||
std::is_convertible<E2, E>::value &&
|
||||
!std::is_convertible<result<U2&, E2> const&, U&>::value
|
||||
>::type>
|
||||
BOOST_CXX14_CONSTEXPR result( result<U2&, E2> const& r2 )
|
||||
noexcept(
|
||||
std::is_nothrow_constructible<U&, U2&>::value &&
|
||||
std::is_nothrow_constructible<E, E2>::value &&
|
||||
std::is_nothrow_default_constructible<E2>::value &&
|
||||
std::is_nothrow_copy_constructible<E2>::value )
|
||||
: v_( in_place_error, r2.error() )
|
||||
{
|
||||
if( r2 )
|
||||
{
|
||||
this->emplace( *r2 );
|
||||
}
|
||||
}
|
||||
|
||||
// queries
|
||||
|
||||
constexpr bool has_value() const noexcept
|
||||
{
|
||||
return v_.index() == 0;
|
||||
}
|
||||
|
||||
constexpr bool has_error() const noexcept
|
||||
{
|
||||
return v_.index() == 1;
|
||||
}
|
||||
|
||||
constexpr explicit operator bool() const noexcept
|
||||
{
|
||||
return v_.index() == 0;
|
||||
}
|
||||
|
||||
// checked value access
|
||||
|
||||
BOOST_CXX14_CONSTEXPR U& value( boost::source_location const& loc = BOOST_CURRENT_LOCATION ) const
|
||||
{
|
||||
if( has_value() )
|
||||
{
|
||||
return *variant2::unsafe_get<0>( v_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw_exception_from_error( variant2::unsafe_get<1>( v_ ), loc );
|
||||
}
|
||||
}
|
||||
|
||||
// unchecked value access
|
||||
|
||||
BOOST_CXX14_CONSTEXPR U* operator->() const noexcept
|
||||
{
|
||||
return has_value()? variant2::unsafe_get<0>( v_ ): 0;
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR U& operator*() const noexcept
|
||||
{
|
||||
BOOST_ASSERT( has_value() );
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
// error access
|
||||
|
||||
constexpr E error() const &
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_copy_constructible<E>::value )
|
||||
{
|
||||
return has_error()? variant2::unsafe_get<1>( v_ ): E();
|
||||
}
|
||||
|
||||
BOOST_CXX14_CONSTEXPR E error() &&
|
||||
noexcept( std::is_nothrow_default_constructible<E>::value && std::is_nothrow_move_constructible<E>::value )
|
||||
{
|
||||
return has_error()? std::move( variant2::unsafe_get<1>( v_ ) ): E();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
template<class A, class En = typename std::enable_if<
|
||||
detail::is_constructible<U&, A>::value &&
|
||||
!detail::reference_to_temporary<U, A>::value
|
||||
>::type>
|
||||
BOOST_CXX14_CONSTEXPR U& emplace( A&& a )
|
||||
{
|
||||
return *v_.template emplace<0>( &static_cast<U&>( a ) );
|
||||
}
|
||||
|
||||
// swap
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void swap( result& r )
|
||||
noexcept( noexcept( v_.swap( r.v_ ) ) )
|
||||
{
|
||||
v_.swap( r.v_ );
|
||||
}
|
||||
|
||||
friend BOOST_CXX14_CONSTEXPR void swap( result & r1, result & r2 )
|
||||
noexcept( noexcept( r1.swap( r2 ) ) )
|
||||
{
|
||||
r1.swap( r2 );
|
||||
}
|
||||
|
||||
// equality
|
||||
|
||||
friend constexpr bool operator==( result const & r1, result const & r2 )
|
||||
noexcept( noexcept( r1 && r2? *r1 == *r2: r1.v_ == r2.v_ ) )
|
||||
{
|
||||
return r1 && r2? *r1 == *r2: r1.v_ == r2.v_;
|
||||
}
|
||||
|
||||
friend constexpr bool operator!=( result const & r1, result const & r2 )
|
||||
noexcept( noexcept( !( r1 == r2 ) ) )
|
||||
{
|
||||
return !( r1 == r2 );
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
|
||||
|
||||
template<class U, class E> constexpr in_place_value_t result<U&, E>::in_place_value;
|
||||
template<class U, class E> constexpr in_place_error_t result<U&, E>::in_place_error;
|
||||
|
||||
#endif
|
||||
|
||||
// operator|
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// is_value_convertible_to
|
||||
|
||||
template<class T, class U> struct is_value_convertible_to: std::is_convertible<T, U>
|
||||
{
|
||||
};
|
||||
|
||||
template<class T, class U> struct is_value_convertible_to<T, U&>:
|
||||
std::integral_constant<bool,
|
||||
std::is_lvalue_reference<T>::value &&
|
||||
std::is_convertible<typename std::remove_reference<T>::type*, U*>::value>
|
||||
{
|
||||
};
|
||||
|
||||
// is_result
|
||||
|
||||
template<class T> struct is_result: std::false_type {};
|
||||
template<class T, class E> struct is_result< result<T, E> >: std::true_type {};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// result | value
|
||||
|
||||
template<class T, class E, class U,
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
T operator|( result<T, E> const& r, U&& u )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *r;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<U>( u );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class U,
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
T operator|( result<T, E>&& r, U&& u )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *std::move( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<U>( u );
|
||||
}
|
||||
}
|
||||
|
||||
// result | nullary-returning-value
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
T operator|( result<T, E> const& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *r;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
T operator|( result<T, E>&& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *std::move( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
// result | nullary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<detail::is_value_convertible_to<T, typename U::value_type>::value>::type
|
||||
>
|
||||
U operator|( result<T, E> const& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *r;
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<detail::is_value_convertible_to<T, typename U::value_type>::value>::type
|
||||
>
|
||||
U operator|( result<T, E>&& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return *std::move( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_void<typename U::value_type>::value>::type
|
||||
>
|
||||
U operator|( result<void, E> const& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_void<typename U::value_type>::value>::type
|
||||
>
|
||||
U operator|( result<void, E>&& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
// operator|=
|
||||
|
||||
// result |= value
|
||||
|
||||
template<class T, class E, class U,
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
result<T, E>& operator|=( result<T, E>& r, U&& u )
|
||||
{
|
||||
if( !r )
|
||||
{
|
||||
r = std::forward<U>( u );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// result |= nullary-returning-value
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
result<T, E>& operator|=( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( !r )
|
||||
{
|
||||
r = std::forward<F>( f )();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// result |= nullary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<detail::is_value_convertible_to<typename U::value_type, T>::value>::type,
|
||||
class En3 = typename std::enable_if<std::is_convertible<typename U::error_type, E>::value>::type
|
||||
>
|
||||
result<T, E>& operator|=( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( !r )
|
||||
{
|
||||
r = std::forward<F>( f )();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// operator&
|
||||
|
||||
// result & unary-returning-value
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E>&& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *std::move( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class En = typename std::enable_if<std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<F>( f )( *r );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class En = typename std::enable_if<std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<T, E>&& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<F>( f )( *std::move( r ) );
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<!std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<void, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<std::is_void<U>::value>::type
|
||||
>
|
||||
result<U, E> operator&( result<void, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::forward<F>( f )();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// result & unary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
U operator&( result<T, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *r );
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
U operator&( result<T, E>&& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )( *std::move( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_convertible<E, typename U::error_type>::value>::type
|
||||
>
|
||||
U operator&( result<void, E> const& r, F&& f )
|
||||
{
|
||||
if( r.has_error() )
|
||||
{
|
||||
return r.error();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::forward<F>( f )();
|
||||
}
|
||||
}
|
||||
|
||||
// operator&=
|
||||
|
||||
// result &= unary-returning-value
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class En1 = typename std::enable_if<!detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
|
||||
>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
r = std::forward<F>( f )( *std::move( r ) );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En = typename std::enable_if<!detail::is_result<U>::value>::type
|
||||
>
|
||||
result<void, E>& operator&=( result<void, E>& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
std::forward<F>( f )();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// result &= unary-returning-result
|
||||
|
||||
template<class T, class E, class F,
|
||||
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<detail::is_value_convertible_to<typename U::value_type, T>::value>::type,
|
||||
class En3 = typename std::enable_if<std::is_convertible<typename U::error_type, E>::value>::type
|
||||
>
|
||||
result<T, E>& operator&=( result<T, E>& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
r = std::forward<F>( f )( *std::move( r ) );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class E, class F,
|
||||
class U = decltype( std::declval<F>()() ),
|
||||
class En1 = typename std::enable_if<detail::is_result<U>::value>::type,
|
||||
class En2 = typename std::enable_if<std::is_void<typename U::value_type>::value>::type,
|
||||
class En3 = typename std::enable_if<std::is_convertible<typename U::error_type, E>::value>::type
|
||||
>
|
||||
result<void, E>& operator&=( result<void, E>& r, F&& f )
|
||||
{
|
||||
if( r )
|
||||
{
|
||||
r = std::forward<F>( f )();
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
system_error( int ev, error_category const & ecat, char const * prefix ):
|
||||
std::runtime_error( std::string( prefix ) + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {}
|
||||
|
||||
error_code code() const BOOST_NOEXCEPT
|
||||
error_code code() const noexcept
|
||||
{
|
||||
return code_;
|
||||
}
|
||||
|
@ -13,5 +13,5 @@
|
||||
"Error-handling",
|
||||
"Programming"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
"cxxstd": "11"
|
||||
}
|
||||
|
@ -84,7 +84,6 @@ 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)
|
||||
@ -138,8 +137,6 @@ boost_test(TYPE run SOURCES std_interop_test16.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
|
||||
boost_test(TYPE run SOURCES result_default_construct.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct.cpp)
|
||||
@ -164,3 +161,19 @@ boost_test(TYPE run SOURCES result_error_construct4.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct4.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct5.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_move.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct6.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct7.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct5.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_value.cpp)
|
||||
boost_test(TYPE compile-fail SOURCES result_or_value_fail.cpp)
|
||||
boost_test(TYPE compile-fail SOURCES result_or_value_fail2.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_fn0v.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_fn0r.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_fn1v.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_fn1r.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_eq_fn1v.cpp)
|
||||
boost_test(TYPE run SOURCES result_and_eq_fn1r.cpp)
|
||||
boost_test(TYPE run SOURCES result_in_place_use.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_value.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_fn0v.cpp)
|
||||
boost_test(TYPE run SOURCES result_or_eq_fn0r.cpp)
|
||||
|
@ -17,6 +17,9 @@ project
|
||||
|
||||
: requirements
|
||||
|
||||
<library>/boost/system//boost_system
|
||||
<library>/boost/core//boost_core
|
||||
|
||||
<toolset>msvc:<warnings-as-errors>on
|
||||
<toolset>gcc:<warnings-as-errors>on
|
||||
<toolset>clang:<warnings-as-errors>on
|
||||
@ -75,7 +78,9 @@ system-run generic_category_test.cpp ;
|
||||
system-run system_category_test.cpp ;
|
||||
system-run after_main_test.cpp ;
|
||||
system-run failed_test.cpp ;
|
||||
system-run failed_constexpr_test.cpp ;
|
||||
run failed_constexpr_test.cpp : : :
|
||||
# GCC w/ UBSAN doesn't consider `cat_ != 0` a constant expression
|
||||
<toolset>gcc,<undefined-sanitizer>norecover:<build>no ;
|
||||
|
||||
# Quick (CI) test
|
||||
run quick.cpp ;
|
||||
@ -106,7 +111,6 @@ 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 ;
|
||||
@ -166,31 +170,43 @@ run std_interop_test16.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
CPP11 = [ requires cxx11_variadic_templates cxx11_template_aliases cxx11_decltype cxx11_constexpr cxx11_noexcept ] <toolset>gcc-4.7:<build>no ;
|
||||
|
||||
run result_default_construct.cpp : : : $(CPP11) ;
|
||||
run result_value_construct.cpp : : : $(CPP11) ;
|
||||
run result_error_construct.cpp : : : $(CPP11) ;
|
||||
run result_copy_construct.cpp : : : $(CPP11) ;
|
||||
run result_move_construct.cpp : : : $(CPP11) ;
|
||||
run result_copy_assign.cpp : : : $(CPP11) ;
|
||||
run result_move_assign.cpp : : : $(CPP11) ;
|
||||
run result_value_access.cpp : : : $(CPP11) ;
|
||||
run result_error_access.cpp : : : $(CPP11) ;
|
||||
run result_swap.cpp : : : $(CPP11) <toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized" ;
|
||||
run result_eq.cpp : : : $(CPP11) ;
|
||||
run result_range_for.cpp : : : $(CPP11) ;
|
||||
run result_value_construct2.cpp : : : $(CPP11) ;
|
||||
run result_error_construct2.cpp : : : $(CPP11) ;
|
||||
run result_errc_construct.cpp : : : $(CPP11) ;
|
||||
run result_convert_construct.cpp : : : $(CPP11) ;
|
||||
run result_typedefs.cpp : : : $(CPP11) ;
|
||||
run result_value_construct3.cpp : : : $(CPP11) ;
|
||||
run result_error_construct3.cpp : : : $(CPP11) ;
|
||||
run result_emplace.cpp : : : $(CPP11) ;
|
||||
run result_error_construct4.cpp : : : $(CPP11) ;
|
||||
run result_value_construct4.cpp : : : $(CPP11) ;
|
||||
run result_value_construct5.cpp : : : $(CPP11) ;
|
||||
run result_error_move.cpp : : : $(CPP11) ;
|
||||
run result_default_construct.cpp ;
|
||||
run result_value_construct.cpp ;
|
||||
run result_error_construct.cpp ;
|
||||
run result_copy_construct.cpp ;
|
||||
run result_move_construct.cpp ;
|
||||
run result_copy_assign.cpp ;
|
||||
run result_move_assign.cpp ;
|
||||
run result_value_access.cpp ;
|
||||
run result_error_access.cpp ;
|
||||
run result_swap.cpp : : : <toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized" ;
|
||||
run result_eq.cpp ;
|
||||
run result_range_for.cpp ;
|
||||
run result_value_construct2.cpp ;
|
||||
run result_error_construct2.cpp ;
|
||||
run result_errc_construct.cpp ;
|
||||
run result_convert_construct.cpp ;
|
||||
run result_typedefs.cpp ;
|
||||
run result_value_construct3.cpp ;
|
||||
run result_error_construct3.cpp ;
|
||||
run result_emplace.cpp ;
|
||||
run result_error_construct4.cpp ;
|
||||
run result_value_construct4.cpp ;
|
||||
run result_value_construct5.cpp ;
|
||||
run result_error_move.cpp ;
|
||||
run result_value_construct6.cpp ;
|
||||
run result_value_construct7.cpp ;
|
||||
run result_error_construct5.cpp ;
|
||||
run result_or_value.cpp ;
|
||||
compile-fail result_or_value_fail.cpp ;
|
||||
compile-fail result_or_value_fail2.cpp ;
|
||||
run result_or_fn0v.cpp ;
|
||||
run result_or_fn0r.cpp ;
|
||||
run result_and_fn1v.cpp ;
|
||||
run result_and_fn1r.cpp ;
|
||||
run result_and_eq_fn1v.cpp ;
|
||||
run result_and_eq_fn1r.cpp ;
|
||||
run result_in_place_use.cpp ;
|
||||
run result_or_eq_value.cpp ;
|
||||
run result_or_eq_fn0v.cpp ;
|
||||
run result_or_eq_fn0r.cpp ;
|
||||
|
@ -14,4 +14,4 @@ target_link_libraries(main Boost::system)
|
||||
enable_testing()
|
||||
add_test(main main)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
@ -23,4 +23,4 @@ target_link_libraries(quick Boost::system Boost::core)
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $<CONFIG>)
|
||||
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $<CONFIG>)
|
||||
|
@ -50,16 +50,6 @@ int main()
|
||||
std::cout << "BOOST_NO_ANSI_APIS is defined" << std::endl;
|
||||
#else
|
||||
std::cout << "BOOST_NO_ANSI_APIS is not defined" << std::endl;
|
||||
#endif
|
||||
#ifdef BOOST_NO_CXX11_NOEXCEPT
|
||||
std::cout << "BOOST_NO_CXX11_NOEXCEPT is defined" << std::endl;
|
||||
#else
|
||||
std::cout << "BOOST_NO_CXX11_NOEXCEPT is not defined" << std::endl;
|
||||
#endif
|
||||
#ifdef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
|
||||
std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is defined" << std::endl;
|
||||
#else
|
||||
std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is not defined" << std::endl;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
// 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
|
@ -7,9 +7,7 @@
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cerrno>
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
#include <system_error>
|
||||
#endif
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
@ -69,8 +67,6 @@ int main()
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
// std:: wrapping against normal
|
||||
{
|
||||
std::error_code e1( EINVAL, std::generic_category() );
|
||||
@ -126,7 +122,5 @@ int main()
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -85,8 +85,6 @@ int main()
|
||||
BOOST_TEST_EQ( ec.location().line(), 75 );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
std::error_code e2( val, std::generic_category() );
|
||||
|
||||
@ -107,10 +105,8 @@ int main()
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
BOOST_TEST( ec.has_location() );
|
||||
BOOST_TEST_EQ( ec.location().line(), 100 );
|
||||
BOOST_TEST_EQ( ec.location().line(), 98 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ sys::error_code make_error_code( E e )
|
||||
return e == 0? sys::error_code(): sys::error_code( e, sys::generic_category() );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
enum E2
|
||||
{
|
||||
e2inval = EINVAL
|
||||
@ -57,8 +55,6 @@ std::error_code make_error_code( E2 e )
|
||||
return std::error_code( e, std::generic_category() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -84,7 +80,7 @@ int main()
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
BOOST_TEST( ec.has_location() );
|
||||
BOOST_TEST_EQ( ec.location().line(), 77 );
|
||||
BOOST_TEST_EQ( ec.location().line(), 73 );
|
||||
}
|
||||
|
||||
{
|
||||
@ -134,7 +130,7 @@ int main()
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
BOOST_TEST( ec.has_location() );
|
||||
BOOST_TEST_EQ( ec.location().line(), 127 );
|
||||
BOOST_TEST_EQ( ec.location().line(), 123 );
|
||||
}
|
||||
|
||||
{
|
||||
@ -182,7 +178,7 @@ int main()
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
BOOST_TEST( ec.has_location() );
|
||||
BOOST_TEST_EQ( ec.location().line(), 175 );
|
||||
BOOST_TEST_EQ( ec.location().line(), 171 );
|
||||
}
|
||||
|
||||
{
|
||||
@ -209,8 +205,6 @@ int main()
|
||||
BOOST_TEST_EQ( ec.location().line(), 0 );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
sys::error_code ec( e2inval );
|
||||
|
||||
@ -281,7 +275,5 @@ int main()
|
||||
BOOST_TEST_EQ( ec.location().line(), 0 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -57,8 +57,6 @@ int main()
|
||||
BOOST_TEST_EQ( ec3.location(), boost::source_location() );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
std::error_code e2( val, std::generic_category() );
|
||||
|
||||
@ -84,7 +82,5 @@ int main()
|
||||
BOOST_TEST_EQ( ec3.location(), boost::source_location() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -59,8 +59,6 @@ int main()
|
||||
BOOST_TEST_EQ( ec.location(), boost::source_location() );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
std::error_code e2( val, std::generic_category() );
|
||||
|
||||
@ -87,7 +85,5 @@ int main()
|
||||
BOOST_TEST_EQ( ec.location(), boost::source_location() );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ int main()
|
||||
BOOST_TEST_EQ( ec.what(), ec.message() + " [system:5 at " + loc.to_string() + "]" );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
std::error_code ec;
|
||||
sys::error_code ec2( ec );
|
||||
@ -85,7 +83,5 @@ int main()
|
||||
BOOST_TEST_EQ( ec2.what(), ec2.message() + " [std:system:5]" );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class user_category: public sys::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
virtual const char * name() const noexcept
|
||||
{
|
||||
return "user";
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class user_category: public sys::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
virtual const char * name() const noexcept
|
||||
{
|
||||
return "user";
|
||||
}
|
||||
|
@ -11,26 +11,53 @@ namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
char buffer[ 1024 ];
|
||||
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_EQ( ec.value(), 0 );
|
||||
BOOST_TEST( ec.category() == sys::system_category() );
|
||||
BOOST_TEST_EQ( ec.message(), ec.category().message( ec.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec.message( buffer, sizeof( buffer ) ), ec.category().message( ec.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST( !ec.failed() );
|
||||
BOOST_TEST( !ec );
|
||||
|
||||
BOOST_TEST_EQ( ec.to_string(), std::string( "system:0" ) );
|
||||
char buffer[ 4096 ], buffer2[ 4096 ];
|
||||
|
||||
{
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_EQ( ec.value(), 0 );
|
||||
BOOST_TEST( ec.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec.message(), ec.category().message( ec.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec.message( buffer, sizeof( buffer ) ), ec.category().message( ec.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec.message( buffer, sizeof( buffer ) ), ec.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !ec.failed() );
|
||||
BOOST_TEST( !ec );
|
||||
|
||||
BOOST_TEST_EQ( ec.to_string(), std::string( "system:0" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec;
|
||||
sys::error_code ec2( ec );
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), 0 );
|
||||
BOOST_TEST( ec2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !ec2.failed() );
|
||||
BOOST_TEST( !ec2 );
|
||||
|
||||
@ -41,12 +68,25 @@ int main()
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec;
|
||||
sys::error_code ec2( ec.value(), ec.category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), 0 );
|
||||
BOOST_TEST( ec2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !ec2.failed() );
|
||||
BOOST_TEST( !ec2 );
|
||||
|
||||
@ -61,34 +101,124 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), 5 );
|
||||
BOOST_TEST( ec2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( ec2.failed() );
|
||||
BOOST_TEST( ec2 );
|
||||
BOOST_TEST_NOT( !ec2 );
|
||||
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_NE( ec, ec2 );
|
||||
BOOST_TEST_NOT( ec == ec2 );
|
||||
|
||||
BOOST_TEST_EQ( ec2.to_string(), std::string( "generic:5" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec2( -4, sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), -4 );
|
||||
BOOST_TEST( ec2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( ec2.failed() );
|
||||
BOOST_TEST( ec2 );
|
||||
BOOST_TEST_NOT( !ec2 );
|
||||
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_NE( ec, ec2 );
|
||||
BOOST_TEST_NOT( ec == ec2 );
|
||||
|
||||
BOOST_TEST_EQ( ec2.to_string(), std::string( "generic:-4" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec2( 5, sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), 5 );
|
||||
BOOST_TEST( ec2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( ec2.failed() );
|
||||
BOOST_TEST( ec2 );
|
||||
BOOST_TEST_NOT( !ec2 );
|
||||
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_NE( ec, ec2 );
|
||||
BOOST_TEST_NOT( ec == ec2 );
|
||||
|
||||
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:5" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec2( -4, sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.value(), -4 );
|
||||
BOOST_TEST( ec2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = ec2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( ec2.failed() );
|
||||
BOOST_TEST( ec2 );
|
||||
BOOST_TEST_NOT( !ec2 );
|
||||
|
||||
sys::error_code ec;
|
||||
|
||||
BOOST_TEST_NE( ec, ec2 );
|
||||
BOOST_TEST_NOT( ec == ec2 );
|
||||
|
||||
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:-4" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -11,26 +11,53 @@ namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
char buffer[ 1024 ];
|
||||
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_EQ( en.value(), 0 );
|
||||
BOOST_TEST( en.category() == sys::generic_category() );
|
||||
BOOST_TEST_EQ( en.message(), en.category().message( en.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en.message( buffer, sizeof( buffer ) ), en.category().message( en.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST( !en.failed() );
|
||||
BOOST_TEST( !en );
|
||||
|
||||
BOOST_TEST_EQ( en.to_string(), std::string( "cond:generic:0" ) );
|
||||
char buffer[ 4096 ], buffer2[ 4096 ];
|
||||
|
||||
{
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_EQ( en.value(), 0 );
|
||||
BOOST_TEST( en.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en.message(), en.category().message( en.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en.message( buffer, sizeof( buffer ) ), en.category().message( en.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en.message( buffer, sizeof( buffer ) ), en.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !en.failed() );
|
||||
BOOST_TEST( !en );
|
||||
|
||||
BOOST_TEST_EQ( en.to_string(), std::string( "cond:generic:0" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_condition en;
|
||||
sys::error_condition en2( en );
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), 0 );
|
||||
BOOST_TEST( en2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !en2.failed() );
|
||||
BOOST_TEST( !en2 );
|
||||
|
||||
@ -41,12 +68,25 @@ int main()
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_condition en;
|
||||
sys::error_condition en2( en.value(), en.category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), 0 );
|
||||
BOOST_TEST( en2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( !en2.failed() );
|
||||
BOOST_TEST( !en2 );
|
||||
|
||||
@ -61,34 +101,124 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), 5 );
|
||||
BOOST_TEST( en2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( en2.failed() );
|
||||
BOOST_TEST( en2 );
|
||||
BOOST_TEST_NOT( !en2 );
|
||||
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_NE( en, en2 );
|
||||
BOOST_TEST_NOT( en == en2 );
|
||||
|
||||
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:5" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_condition en2( -4, sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), -4 );
|
||||
BOOST_TEST( en2.category() == sys::generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( en2.failed() );
|
||||
BOOST_TEST( en2 );
|
||||
BOOST_TEST_NOT( !en2 );
|
||||
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_NE( en, en2 );
|
||||
BOOST_TEST_NOT( en == en2 );
|
||||
|
||||
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:-4" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_condition en2( 5, sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), 5 );
|
||||
BOOST_TEST( en2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer, sizeof( buffer ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( en2.failed() );
|
||||
BOOST_TEST( en2 );
|
||||
BOOST_TEST_NOT( !en2 );
|
||||
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_NE( en, en2 );
|
||||
BOOST_TEST_NOT( en == en2 );
|
||||
|
||||
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:system:5" ) );
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_condition en2( -4, sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.value(), -4 );
|
||||
BOOST_TEST( en2.category() == sys::system_category() );
|
||||
|
||||
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
|
||||
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
|
||||
|
||||
{
|
||||
char const* msg = en2.message( nullptr, 0 );
|
||||
|
||||
if( msg != nullptr )
|
||||
{
|
||||
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_TEST( en2.failed() );
|
||||
BOOST_TEST( en2 );
|
||||
BOOST_TEST_NOT( !en2 );
|
||||
|
||||
sys::error_condition en;
|
||||
|
||||
BOOST_TEST_NE( en, en2 );
|
||||
BOOST_TEST_NOT( en == en2 );
|
||||
|
||||
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:system:-4" ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -13,11 +13,11 @@ struct http_category_impl: public error_category
|
||||
{
|
||||
// clang++ 3.8 and below: initialization of const object
|
||||
// requires a user-provided default constructor
|
||||
BOOST_SYSTEM_CONSTEXPR http_category_impl() BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_CONSTEXPR http_category_impl() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
char const * name() const BOOST_NOEXCEPT
|
||||
char const * name() const noexcept
|
||||
{
|
||||
return "http";
|
||||
}
|
||||
@ -30,7 +30,7 @@ struct http_category_impl: public error_category
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool failed( int ev ) const BOOST_NOEXCEPT
|
||||
bool failed( int ev ) const noexcept
|
||||
{
|
||||
return !( ev >= 200 && ev < 300 );
|
||||
}
|
||||
|
149
test/result_and_eq_fn1r.cpp
Normal file
149
test/result_and_eq_fn1r.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& r )
|
||||
{
|
||||
if( &r != this )
|
||||
{
|
||||
v_ = r.v_;
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
struct E2
|
||||
{
|
||||
E2() {}
|
||||
E2( E ) {}
|
||||
};
|
||||
|
||||
result<int, E> fi( int x )
|
||||
{
|
||||
return 2 * x + 1;
|
||||
}
|
||||
|
||||
result<int, E2> fi2( int )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<X, E> fy( Y y )
|
||||
{
|
||||
return X{ 2 * y.v_ + 1 };
|
||||
}
|
||||
|
||||
result<Y, E2> fy2( Y )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<int&, E> fri( int& )
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
result<int&, E2> fri2( int& )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<void, E2> fv()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<void, E2> fv2()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int, E2> r( 1 );
|
||||
|
||||
r &= fi;
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 3 );
|
||||
|
||||
r &= fi2;
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r &= fi;
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E2> r( in_place_value, 1 );
|
||||
|
||||
r &= fy;
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 3 );
|
||||
|
||||
r &= fy2;
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r &= fy;
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
result<int&, E2> r( x1 );
|
||||
|
||||
r &= fri;
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &*fri( x1 ) );
|
||||
|
||||
r &= fri2;
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r &= fri;
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r;
|
||||
|
||||
r &= fv;
|
||||
BOOST_TEST( r.has_value() );
|
||||
|
||||
r &= fv2;
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r &= fv;
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
141
test/result_and_eq_fn1v.cpp
Normal file
141
test/result_and_eq_fn1v.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& r )
|
||||
{
|
||||
if( &r != this )
|
||||
{
|
||||
v_ = r.v_;
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x * 2 + 1;
|
||||
}
|
||||
|
||||
X g( Y y )
|
||||
{
|
||||
return X{ y.v_ * 2 + 1 };
|
||||
}
|
||||
|
||||
int& h( int& )
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
static int fv_called;
|
||||
|
||||
void fv()
|
||||
{
|
||||
++fv_called;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
r &= f;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
r &= f;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y> r( in_place_value, 1 );
|
||||
|
||||
r &= g;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E> r( in_place_error );
|
||||
|
||||
r &= g;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
result<int&> r( x1 );
|
||||
|
||||
r &= h;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &h( x1 ) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
r &= h;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
fv_called = 0;
|
||||
|
||||
r &= fv;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( fv_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r( in_place_error );
|
||||
fv_called = 0;
|
||||
|
||||
r &= fv;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
BOOST_TEST_EQ( fv_called, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
503
test/result_and_fn1r.cpp
Normal file
503
test/result_and_fn1r.cpp
Normal file
@ -0,0 +1,503 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& ) = delete;
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
struct E2
|
||||
{
|
||||
E2() {}
|
||||
E2( E ) {}
|
||||
};
|
||||
|
||||
result<int, E2> fi( int x )
|
||||
{
|
||||
return 2 * x + 1;
|
||||
}
|
||||
|
||||
result<int, E2> fi2( int )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<void, E2> fi3( int )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<X, E2> fy( Y y )
|
||||
{
|
||||
return X{ 2 * y.v_ + 1 };
|
||||
}
|
||||
|
||||
result<X, E2> fy2( Y )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<void, E2> fy3( Y )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<int, E2> fri( int& x )
|
||||
{
|
||||
return x * 2 + 1;
|
||||
}
|
||||
|
||||
result<int&, E2> fri2( int& )
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<void, E2> fri3( int& )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<int, E2> fk()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
result<int, E2> fk2()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<void, E2> fk3()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<void, E2> fk4()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int, E> r( 1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fi3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> const r( 1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fi3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<int, E>( 1 ) & fi;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<int, E>( 1 ) & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<int, E>( 1 ) & fi3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fi3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> const r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fi3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<int, E>( in_place_error ) & fi;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<int, E>( in_place_error ) & fi2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<int, E>( in_place_error ) & fi3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( r2->v_, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy3;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E2> r2 = result<Y, E>( in_place_error ) & fy;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E2> r2 = result<Y, E>( in_place_error ) & fy2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<Y, E>( in_place_error ) & fy3;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
result<int&, E> r( x1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fri;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fri3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
result<int&, E> const r( x1 );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fri;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fri3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int, E2> r2 = result<int&, E>( x1 ) & fri;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&, E2> r2 = result<int&, E>( x1 ) & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<void, E2> r2 = result<int&, E>( x1 ) & fri3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fri;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fri3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fri;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = r & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fri3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<int&, E>( in_place_error ) & fri;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r2 = result<int&, E>( in_place_error ) & fri2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<int&, E>( in_place_error ) & fri3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r;
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> const r;
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<void, E>() & fk;
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<void, E>() & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<void, E>() & fk3;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<void, E>() & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> const r( in_place_error );
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = r & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = r & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<void, E>( in_place_error ) & fk;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r2 = result<void, E>( in_place_error ) & fk2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<void, E>( in_place_error ) & fk3;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E2> r2 = result<void, E>( in_place_error ) & fk4;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
331
test/result_and_fn1v.cpp
Normal file
331
test/result_and_fn1v.cpp
Normal file
@ -0,0 +1,331 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& ) = delete;
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int f( int x )
|
||||
{
|
||||
return x * 2 + 1;
|
||||
}
|
||||
|
||||
X g( Y y )
|
||||
{
|
||||
return X{ y.v_ * 2 + 1 };
|
||||
}
|
||||
|
||||
int& h( int& )
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
int k()
|
||||
{
|
||||
return 7;
|
||||
}
|
||||
|
||||
static int fv1_called_with;
|
||||
|
||||
void fv1( int x )
|
||||
{
|
||||
fv1_called_with = x;
|
||||
}
|
||||
|
||||
static int fv2_called;
|
||||
|
||||
void fv2()
|
||||
{
|
||||
++fv2_called;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
result<int> r2 = r & f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
result<int> r2 = r & f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r2 = result<int>( 1 ) & f;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
result<int, E> r2 = r & f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> const r( in_place_error );
|
||||
result<int, E> r2 = r & f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r2 = result<int, E>( in_place_error ) & f;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r2 = result<Y>( in_place_value, 1 ) & g;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( r2->v_, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X, E> r2 = result<Y, E>( in_place_error ) & g;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
result<int&> r2 = r & h;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
result<int&> r2 = r & h;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r2 = result<int&>( x1 ) & h;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
result<int&, E> r2 = r & h;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
result<int&, E> r2 = r & h;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r2 = result<int&, E>( in_place_error ) & h;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<int> r2 = r & k;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> const r;
|
||||
result<int> r2 = r & k;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r2 = result<void>() & k;
|
||||
|
||||
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r( in_place_error );
|
||||
result<int, E> r2 = r & k;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> const r( in_place_error );
|
||||
result<int, E> r2 = r & k;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r2 = result<void, E>( in_place_error ) & k;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
fv1_called_with = 0;
|
||||
|
||||
result<int> r( 1 );
|
||||
result<void> r2 = r & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
result<void> r2 = r & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
fv1_called_with = 0;
|
||||
|
||||
result<void> r2 = result<int>( 1 ) & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
fv1_called_with = 0;
|
||||
|
||||
result<int, E> r( in_place_error );
|
||||
result<void, E> r2 = r & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
fv1_called_with = 0;
|
||||
|
||||
result<int, E> const r( in_place_error );
|
||||
result<void, E> r2 = r & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
fv1_called_with = 0;
|
||||
|
||||
result<void, E> r2 = result<int, E>( in_place_error ) & fv1;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv1_called_with, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
fv2_called = 0;
|
||||
|
||||
result<void> r2 = r & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv2_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> const r;
|
||||
fv2_called = 0;
|
||||
|
||||
result<void> r2 = r & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv2_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
fv2_called = 0;
|
||||
|
||||
result<void> r2 = result<void>() & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST_EQ( fv2_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r( in_place_error );
|
||||
fv2_called = 0;
|
||||
|
||||
result<void, E> r2 = r & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv2_called, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> const r( in_place_error );
|
||||
fv2_called = 0;
|
||||
|
||||
result<void, E> r2 = r & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv2_called, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
fv2_called = 0;
|
||||
|
||||
result<void, E> r2 = result<void, E>( in_place_error ) & fv2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
BOOST_TEST_EQ( fv2_called, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -181,6 +181,95 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void, int> r;
|
||||
result<void, X> r2 = r;
|
||||
|
||||
BOOST_TEST( r2 );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<void, int> const r;
|
||||
result<void, X> r2 = r;
|
||||
|
||||
BOOST_TEST( r2 );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<void, X> r2 = result<void, int>();
|
||||
|
||||
BOOST_TEST( r2 );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<void, int> r( 5 );
|
||||
result<void, X> r2 = r;
|
||||
|
||||
BOOST_TEST( !r2 );
|
||||
BOOST_TEST_EQ( r2.error(), X(5) );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<void, int> const r( 6 );
|
||||
result<void, X> r2 = r;
|
||||
|
||||
BOOST_TEST( !r2 );
|
||||
BOOST_TEST_EQ( r2.error(), X(6) );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, X> r2 = result<void, int>( 7 );
|
||||
|
||||
BOOST_TEST( !r2 );
|
||||
BOOST_TEST_EQ( r2.error(), X(7) );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x = 5;
|
||||
|
||||
result<int&> r( x );
|
||||
result<int const&> r2 = r;
|
||||
|
||||
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 5 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 6;
|
||||
|
||||
result<int&> const r( x );
|
||||
result<int const&> r2 = r;
|
||||
|
||||
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 6 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 7;
|
||||
|
||||
result<int const&> r2 = result<int&>( x );
|
||||
|
||||
BOOST_TEST( r2 ) && BOOST_TEST_EQ( *r2, 7 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<long>, result<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<result<int>, result<long>>));
|
||||
@ -196,6 +285,21 @@ int main()
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int, void*>, result<int, int>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<int, int>, result<int, void*>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<void, void*>, result<void, int>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<void, int>, result<void, void*>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int const&>, result<int&>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<result<int&>, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<int>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<int>, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<long&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<long&>, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, result<long const&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<result<long const&>, result<int const&>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
@ -682,5 +682,151 @@ int main()
|
||||
BOOST_TEST_EQ( r, r2 );
|
||||
}
|
||||
|
||||
// reference
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
int const x2 = 2;
|
||||
|
||||
result<int const&> r1( x1 );
|
||||
result<int const&> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> const r1( x1 );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
int const x2 = 2;
|
||||
|
||||
result<int const &> const r1( x1 );
|
||||
result<int const &> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r1( x1 );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r1( ec );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r1( ec );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> const r1( ec );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> const r1( ec );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = r1;
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -145,6 +145,8 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<void> r2( r );
|
||||
@ -177,5 +179,121 @@ int main()
|
||||
BOOST_TEST_EQ( r, r2 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r1( x1 );
|
||||
result<int&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
|
||||
result<int const&> r1( x1 );
|
||||
result<int const&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
|
||||
result<int const&> const r1( x1 );
|
||||
result<int const&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
|
||||
result<X&> r1( x1 );
|
||||
result<X&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
|
||||
result<X&> const r1( x1 );
|
||||
result<X&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x1( 1 );
|
||||
|
||||
result<X const&> r1( x1 );
|
||||
result<X const&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x1( 1 );
|
||||
|
||||
result<X const&> const r1( x1 );
|
||||
result<X const&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r1( ec );
|
||||
result<int&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> const r1( ec );
|
||||
result<int&> r2( r1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -28,6 +28,24 @@ int main()
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r{};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r = {};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r;
|
||||
|
||||
@ -35,6 +53,20 @@ int main()
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r{};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<X> r = {};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
|
||||
@ -42,6 +74,20 @@ int main()
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r{};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r = {};
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int, int>>));
|
||||
@ -52,6 +98,9 @@ int main()
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y, int>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<int&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<int&, int>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
@ -172,5 +172,47 @@ int main()
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
result<int&> r( x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
|
||||
int x2 = 2;
|
||||
r.emplace( x2 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value(), 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&> r( ENOENT, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
|
||||
int x2 = 2;
|
||||
r.emplace( x2 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value(), 2 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
{
|
||||
result<int&, Y> r( in_place_error );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST_EQ( Y::instances, 1 );
|
||||
|
||||
int x2 = 2;
|
||||
r.emplace( x2 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( *r, 2 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -149,5 +149,83 @@ int main()
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&> r1( 1, generic_category() );
|
||||
result<int&> r2( 2, generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( 2, generic_category() );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
X x2( 2 );
|
||||
|
||||
result<X&, Y> r1( x1 );
|
||||
result<X&, Y> r2( x2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
X x2( 1 );
|
||||
|
||||
result<X&, Y> r1( x1 );
|
||||
result<X&, Y> r2( x2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<X&, Y> r1( in_place_error, 1 );
|
||||
result<X&, Y> r2( in_place_error, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
|
||||
result<X&, Y> r1( x1 );
|
||||
result<X&, Y> r2( in_place_error, 2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1 );
|
||||
BOOST_TEST_NE( r1, r2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -19,5 +19,14 @@ int main()
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<bool>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<bool>, errc::errc_t>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<int const&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, errc::errc_t>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<double const&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<double const&>, errc::errc_t>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<bool const&>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<bool const&>, errc::errc_t>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -152,6 +152,8 @@ int main()
|
||||
BOOST_TEST_EQ( (result<std::string, X>( "s" ).error().v_), 0 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
|
||||
@ -208,5 +210,71 @@ int main()
|
||||
BOOST_TEST_EQ( result<void>( ec ).error(), ec );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
BOOST_TEST( result<int&>( x1 ).has_value() );
|
||||
BOOST_TEST( !result<int&>( x1 ).has_error() );
|
||||
|
||||
BOOST_TEST_EQ( result<int&>( x1 ).error(), error_code() );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> const r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
BOOST_TEST( !result<int&>( ec ).has_value() );
|
||||
BOOST_TEST( result<int&>( ec ).has_error() );
|
||||
|
||||
BOOST_TEST_EQ( result<int&>( ec ).error(), ec );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -157,5 +157,27 @@ int main()
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
using R = result<int&>;
|
||||
R r( R::in_place_error, ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
using R = result<int&>;
|
||||
R r( R::in_place_error, EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ int main()
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
{
|
||||
auto ec = make_error_code( std::errc::invalid_argument );
|
||||
|
||||
@ -43,7 +41,5 @@ int main()
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
160
test/result_error_construct5.cpp
Normal file
160
test/result_error_construct5.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
// Copyright 2017, 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
X(): v_() { ++instances; }
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( int v1, int v2 ): v_( v1+v2 ) { ++instances; }
|
||||
X( int v1, int v2, int v3 ): v_( v1+v2+v3 ) { ++instances; }
|
||||
|
||||
X( X const& r ): v_( r.v_ ) { ++instances; }
|
||||
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r = ec;
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&> r( EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<error_code&> r( in_place_error, ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
result<error_code&> r( in_place_error, EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<std::string&, X> r( 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<int&, X> r( 1, 2 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1+2 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<int&, X> r( 1, 2, 3 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1+2+3 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<X&, X> r( in_place_error, 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int&>, error_code>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<error_code, result<int&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<std::string&, X>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<std::string&, X>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int&, X>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<int&, X>>));
|
||||
|
||||
// There's an ambiguity here between int& and X, but since is_convertible
|
||||
// is true, is_constructible can't be false.
|
||||
|
||||
// BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int&, X>, int&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<int&, result<int&, X>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -55,7 +55,9 @@ int main()
|
||||
BOOST_TEST_EQ( (result<std::string, X>( "s" ).error().v_), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
//
|
||||
|
||||
{
|
||||
result<void, X> r( 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
@ -87,5 +89,45 @@ int main()
|
||||
BOOST_TEST_EQ( (result<void, X>().error().v_), 0 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<double&, X> r( 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST(( !result<double&, X>( 1 ).has_value() ));
|
||||
BOOST_TEST(( result<double&, X>( 1 ).has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<double&, X>( 1 ).error().v_), 1 );
|
||||
}
|
||||
|
||||
{
|
||||
double x = 1.0;
|
||||
|
||||
result<double&, X> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( std::move( r ).error().v_, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
double x = 1.0;
|
||||
|
||||
BOOST_TEST(( result<double&, X>( x ).has_value() ));
|
||||
BOOST_TEST(( !result<double&, X>( x ).has_error() ));
|
||||
|
||||
BOOST_TEST_EQ( (result<double&, X>( x ).error().v_), 0 );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
22
test/result_in_place_use.cpp
Normal file
22
test/result_in_place_use.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T, class U> void test( T const& t, U const& u )
|
||||
{
|
||||
BOOST_TEST_NE( static_cast<void const*>( &t ), static_cast<void const*>( &u ) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::system;
|
||||
|
||||
test( result<int>::in_place_value, result<int>::in_place_error );
|
||||
test( result<void>::in_place_value, result<void>::in_place_error );
|
||||
test( result<int&>::in_place_value, result<int&>::in_place_error );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -508,6 +508,8 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<void> r2;
|
||||
@ -600,5 +602,110 @@ int main()
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( x2 );
|
||||
|
||||
r2 = std::move( r1 );
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
BOOST_TEST_EQ( x2, 2 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
BOOST_TEST_EQ( &*r1, &*r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = std::move( r1 );
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r1( ec );
|
||||
result<int&> r2( x1 );
|
||||
|
||||
r2 = std::move( r1 );
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
|
||||
BOOST_TEST( !r2.has_value() );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r2( x1 );
|
||||
|
||||
r2 = result<int&>( ec );
|
||||
|
||||
BOOST_TEST_EQ( x1, 1 );
|
||||
|
||||
BOOST_TEST( !r2.has_value() );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r1( ec );
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = std::move( r1 );
|
||||
|
||||
BOOST_TEST( !r2.has_value() );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r2( ENOENT, generic_category() );
|
||||
|
||||
r2 = result<int&>( ec );
|
||||
|
||||
BOOST_TEST( !r2.has_value() );
|
||||
BOOST_TEST( r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -207,6 +207,8 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<void> r2( std::move( r ) );
|
||||
@ -245,5 +247,149 @@ int main()
|
||||
BOOST_TEST_EQ( r2.error(), ec );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 );
|
||||
result<int&> r2( std::move( r1 ) );
|
||||
|
||||
BOOST_TEST( r1.has_value() );
|
||||
BOOST_TEST( !r1.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r1.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r1, &x1 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
|
||||
result<int const&> r1( x1 );
|
||||
result<int const&> r2( std::move( r1 ) );
|
||||
|
||||
BOOST_TEST( r1.has_value() );
|
||||
BOOST_TEST( !r1.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r1.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r1, &x1 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r2(( result<int&>( x1 ) ));
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x1 = 1;
|
||||
|
||||
result<int const&> r2(( result<int const&>( x1 ) ));
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value(), 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
|
||||
result<X&> r1( x1 );
|
||||
result<X&> r2( std::move( r1 ) );
|
||||
|
||||
BOOST_TEST( r1.has_value() );
|
||||
BOOST_TEST( !r1.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r1.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r1, &x1 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x1( 1 );
|
||||
|
||||
result<X&> r2(( result<X&>( x1 ) ));
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x1( 1 );
|
||||
|
||||
result<X const&> r1( x1 );
|
||||
result<X const&> r2( std::move( r1 ) );
|
||||
|
||||
BOOST_TEST( r1.has_value() );
|
||||
BOOST_TEST( !r1.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r1.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r1, &x1 );
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x1( 1 );
|
||||
|
||||
result<X const&> r2(( result<X const&>( x1 ) ));
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
BOOST_TEST( !r2.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r2.value().v_, 1 );
|
||||
BOOST_TEST_EQ( &*r2, &x1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
160
test/result_or_eq_fn0r.cpp
Normal file
160
test/result_or_eq_fn0r.cpp
Normal file
@ -0,0 +1,160 @@
|
||||
// Copyright 2017, 2021-2024 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& r )
|
||||
{
|
||||
if( &r != this )
|
||||
{
|
||||
v_ = r.v_;
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
struct E2
|
||||
{
|
||||
E2() {}
|
||||
E2( E ) {}
|
||||
};
|
||||
|
||||
result<int, E> fi()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
result<int, E2> fi2()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<X, E> fy()
|
||||
{
|
||||
return X{ 2 };
|
||||
}
|
||||
|
||||
result<Y, E2> fy2()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
result<int&, E> fri()
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
result<int&, E2> fri2()
|
||||
{
|
||||
return E2();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int, E2> r( 1 );
|
||||
|
||||
r |= fi;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 1 );
|
||||
|
||||
r |= fi2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E2> r( in_place_error );
|
||||
|
||||
r |= fi2;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r |= fi;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E2> r( in_place_value, 1 );
|
||||
|
||||
r |= fy;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 1 );
|
||||
|
||||
r |= fy2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E2> r( in_place_error );
|
||||
|
||||
r |= fy2;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r |= fy;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&, E2> r( x1 );
|
||||
|
||||
r |= fri;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &x1 );
|
||||
|
||||
r |= fri2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E2> r( in_place_error );
|
||||
|
||||
r |= fri2;
|
||||
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
r |= fri;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &*fri() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
115
test/result_or_eq_fn0v.cpp
Normal file
115
test/result_or_eq_fn0v.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
// Copyright 2017, 2021-2024 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& r )
|
||||
{
|
||||
if( &r != this )
|
||||
{
|
||||
v_ = r.v_;
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int f()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
X g()
|
||||
{
|
||||
return { 2 };
|
||||
}
|
||||
|
||||
int& h()
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
r |= f;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
r |= f;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y> r( in_place_value, 1 );
|
||||
|
||||
r |= g;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E> r( in_place_error );
|
||||
|
||||
r |= g;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
r |= h;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
r |= h;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &h() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
102
test/result_or_eq_value.cpp
Normal file
102
test/result_or_eq_value.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
// Copyright 2017, 2021-2024 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& r )
|
||||
{
|
||||
if( &r != this )
|
||||
{
|
||||
v_ = r.v_;
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
r |= 2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
r |= 2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y> r( in_place_value, 1 );
|
||||
|
||||
r |= X{2};
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<Y, E> r( in_place_error );
|
||||
|
||||
r |= X{2};
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
r |= x2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
r |= x2;
|
||||
|
||||
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &x2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
359
test/result_or_fn0r.cpp
Normal file
359
test/result_or_fn0r.cpp
Normal file
@ -0,0 +1,359 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& ) = delete;
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
result<int, E> fi()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
result<int, E> fi2()
|
||||
{
|
||||
return E();
|
||||
}
|
||||
|
||||
result<Y, E> fy()
|
||||
{
|
||||
return Y{ 2 };
|
||||
}
|
||||
|
||||
result<Y, E> fy2()
|
||||
{
|
||||
return E();
|
||||
}
|
||||
|
||||
result<int&, E> fri()
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
result<int&, E> fri2()
|
||||
{
|
||||
return E();
|
||||
}
|
||||
|
||||
result<void, E> fv()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
result<void, E> fv2()
|
||||
{
|
||||
return E();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
int x = r | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
|
||||
int x = r | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( 1 ) | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
int x = r | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
|
||||
int x = r | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( 1 ) | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r( in_place_error );
|
||||
|
||||
int x = r | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( in_place_error );
|
||||
|
||||
int x = r | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( in_place_error ) | fi | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r( in_place_error );
|
||||
|
||||
int x = r | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( in_place_error );
|
||||
|
||||
int x = r | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( in_place_error ) | fi2 | 3;
|
||||
|
||||
BOOST_TEST_EQ( x, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<X>( X{1} ) | fy | X{3};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<X>( X{1} ) | fy2 | X{3};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<X, E>( in_place_error ) | fy | X{3};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<X, E>( in_place_error ) | fy2 | Y{3};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&>( x1 ) | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&>( x1 ) | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | fri | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &*fri() );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
}
|
||||
|
||||
{
|
||||
int x3 = 3;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | fri2 | x3;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x3 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<void, E> r2 = r | fv;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
result<void, E> r2 = r | fv2;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r( in_place_error );
|
||||
result<void, E> r2 = r | fv;
|
||||
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r( in_place_error );
|
||||
result<void, E> r2 = r | fv2;
|
||||
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>() | fv;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>() | fv2;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>( in_place_error ) | fv;
|
||||
BOOST_TEST( r2.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void, E> r2 = result<void>( in_place_error ) | fv2;
|
||||
BOOST_TEST( r2.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
162
test/result_or_fn0v.cpp
Normal file
162
test/result_or_fn0v.cpp
Normal file
@ -0,0 +1,162 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& ) = delete;
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int f()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
X g()
|
||||
{
|
||||
return { 2 };
|
||||
}
|
||||
|
||||
int& h()
|
||||
{
|
||||
static int x = 2;
|
||||
return x;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
int x = r | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
|
||||
int x = r | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( 1 ) | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
int x = r | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> const r( in_place_error );
|
||||
|
||||
int x = r | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int, E>( in_place_error ) | f;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y>( in_place_value, 1 ) | g;
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y, E>( in_place_error ) | g;
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
int& x = result<int&>( x1 ) | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &h() );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &h() );
|
||||
}
|
||||
|
||||
{
|
||||
int& x = result<int&, E>( in_place_error ) | h;
|
||||
|
||||
BOOST_TEST_EQ( &x, &h() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
167
test/result_or_value.cpp
Normal file
167
test/result_or_value.cpp
Normal file
@ -0,0 +1,167 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
int v_;
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
int v_;
|
||||
|
||||
explicit Y( int v ): v_( v ) {}
|
||||
Y( X x ): v_( x.v_) {}
|
||||
|
||||
Y( Y const& ) = delete;
|
||||
Y& operator=( Y const& ) = delete;
|
||||
|
||||
Y( Y&& r ): v_( r.v_ )
|
||||
{
|
||||
r.v_ = 0;
|
||||
}
|
||||
|
||||
Y& operator=( Y&& ) = delete;
|
||||
};
|
||||
|
||||
struct E
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r( 1 );
|
||||
|
||||
int x = r | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> const r( 1 );
|
||||
|
||||
int x = r | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int>( 1 ) | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> r( in_place_error );
|
||||
|
||||
int x = r | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int, E> const r( in_place_error );
|
||||
|
||||
int x = r | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = result<int, E>( in_place_error ) | 2;
|
||||
|
||||
BOOST_TEST_EQ( x, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y>( in_place_value, 1 ) | Y{2};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y, E>( in_place_error ) | Y{2};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y>( in_place_value, 1 ) | X{2};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
Y y = result<Y, E>( in_place_error ) | X{2};
|
||||
|
||||
BOOST_TEST_EQ( y.v_, 2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
int& x = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
int& x = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
int& x = result<int&>( x1 ) | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
result<int&, E> r( in_place_error );
|
||||
|
||||
int& x = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
result<int&, E> const r( in_place_error );
|
||||
|
||||
int& x = r | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
}
|
||||
|
||||
{
|
||||
int x2 = 2;
|
||||
|
||||
int& x = result<int&, E>( in_place_error ) | x2;
|
||||
|
||||
BOOST_TEST_EQ( &x, &x2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
14
test/result_or_value_fail.cpp
Normal file
14
test/result_or_value_fail.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 1;
|
||||
result<int const&> r( x );
|
||||
r | 2;
|
||||
}
|
13
test/result_or_value_fail2.cpp
Normal file
13
test/result_or_value_fail2.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2017, 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
int x = 1;
|
||||
result<int const&>( x ) | 2;
|
||||
}
|
@ -259,5 +259,55 @@ int main()
|
||||
BOOST_TEST_EQ( r2, r2c );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
int x2 = 2;
|
||||
|
||||
result<int&> r1( x1 ), r1c( r1 );
|
||||
result<int&> r2( x2 ), r2c( r2 );
|
||||
|
||||
r1.swap( r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2c );
|
||||
BOOST_TEST_EQ( r2, r1c );
|
||||
|
||||
swap( r1, r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1c );
|
||||
BOOST_TEST_EQ( r2, r2c );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&> r1( 1, generic_category() ), r1c( r1 );
|
||||
result<int&> r2( 2, generic_category() ), r2c( r2 );
|
||||
|
||||
r1.swap( r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2c );
|
||||
BOOST_TEST_EQ( r2, r1c );
|
||||
|
||||
swap( r1, r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1c );
|
||||
BOOST_TEST_EQ( r2, r2c );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r1( x1 ), r1c( r1 );
|
||||
result<int&> r2( 2, generic_category() ), r2c( r2 );
|
||||
|
||||
r1.swap( r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r2c );
|
||||
BOOST_TEST_EQ( r2, r1c );
|
||||
|
||||
swap( r1, r2 );
|
||||
|
||||
BOOST_TEST_EQ( r1, r1c );
|
||||
BOOST_TEST_EQ( r2, r2c );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -12,11 +12,28 @@ struct X {};
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME( result<int>::value_type, int );
|
||||
BOOST_TEST_TRAIT_SAME( result<X>::value_type, X );
|
||||
BOOST_TEST_TRAIT_SAME( result<void>::value_type, void );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<int>::error_type, error_code );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<X>::value_type, X );
|
||||
BOOST_TEST_TRAIT_SAME( result<X>::error_type, error_code );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<void>::value_type, void );
|
||||
BOOST_TEST_TRAIT_SAME( result<void>::error_type, error_code );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<int&>::value_type, int& );
|
||||
BOOST_TEST_TRAIT_SAME( result<int&>::error_type, error_code );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<int, X>::value_type, int );
|
||||
BOOST_TEST_TRAIT_SAME( result<int, X>::error_type, X );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<X, X>::value_type, X );
|
||||
BOOST_TEST_TRAIT_SAME( result<X, X>::error_type, X );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<void, X>::value_type, void );
|
||||
BOOST_TEST_TRAIT_SAME( result<void, X>::error_type, X );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<int&, X>::value_type, int& );
|
||||
BOOST_TEST_TRAIT_SAME( result<int&, X>::error_type, X );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -336,6 +336,8 @@ int main()
|
||||
BOOST_TEST_EQ( (result<X, Y>( ec ).operator->()), static_cast<X*>(0) );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
|
||||
@ -497,5 +499,179 @@ int main()
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<void*>(0) );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> r( x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST( r );
|
||||
BOOST_TEST_NOT( !r );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), &*r );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
result<int&> const r( x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST( r );
|
||||
BOOST_TEST_NOT( !r );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), &*r );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
BOOST_TEST( result<int&>( x1 ).has_value() );
|
||||
BOOST_TEST( !result<int&>( x1 ).has_error() );
|
||||
|
||||
BOOST_TEST( result<int&>( x1 ) );
|
||||
BOOST_TEST_NOT( !result<int&>( x1 ) );
|
||||
|
||||
BOOST_TEST_EQ( result<int&>( x1 ).value(), 1 );
|
||||
BOOST_TEST_EQ( *result<int&>( x1 ), 1 );
|
||||
|
||||
BOOST_TEST_EQ( result<int&>( x1 ).operator->(), &x1 );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), system_error );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
result<int&> const r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), system_error );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
BOOST_TEST( !result<int&>( ec ).has_value() );
|
||||
BOOST_TEST( result<int&>( ec ).has_error() );
|
||||
|
||||
BOOST_TEST_NOT( result<int&>( ec ) );
|
||||
BOOST_TEST( !result<int&>( ec ) );
|
||||
|
||||
BOOST_TEST_THROWS( result<int&>( ec ).value(), system_error );
|
||||
|
||||
BOOST_TEST_EQ( result<int&>( ec ).operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( std::errc::invalid_argument );
|
||||
|
||||
result<int&, std::error_code> const r( ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), std::system_error );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, errc::errc_t> const r( in_place_error, errc::invalid_argument );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), system_error );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, std::errc> const r( std::errc::invalid_argument );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), std::system_error );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, std::exception_ptr> const r( std::make_exception_ptr( E2() ) );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
#if defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 30600
|
||||
#else
|
||||
BOOST_TEST_THROWS( r.value(), E2 );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
{
|
||||
result<int&, std::exception_ptr> const r( in_place_error );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
BOOST_TEST_THROWS( r.value(), std::bad_exception );
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -69,6 +69,11 @@ result<std::vector<int>> fv2()
|
||||
return {{ 1, 2 }};
|
||||
}
|
||||
|
||||
result<void> fw0()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -148,5 +153,12 @@ int main()
|
||||
BOOST_TEST_EQ( r->at(1), 2 );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r = fw0();
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
@ -114,5 +114,29 @@ int main()
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
using R = result<int&>;
|
||||
R r( R::in_place_value, x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int x1 = 1;
|
||||
|
||||
using R = result<int&, int>;
|
||||
R r( R::in_place_value, x1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
121
test/result_value_construct6.cpp
Normal file
121
test/result_value_construct6.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright 2017, 2021, 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( X const& ) = delete;
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
result<int&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 0;
|
||||
result<int&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 1;
|
||||
result<int&, int> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X&, X> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r->v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int&>, int&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<int&, result<int&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int&>, int const&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int const&, result<int&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int&>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<int&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int&, int>, int&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int&, float>, int&>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<X&>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<X&>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
211
test/result_value_construct7.cpp
Normal file
211
test/result_value_construct7.cpp
Normal file
@ -0,0 +1,211 @@
|
||||
// Copyright 2017, 2021, 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( X const& ) = delete;
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int x = 0;
|
||||
result<int const&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x = 0;
|
||||
result<int const&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 0;
|
||||
result<int const&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x = 0;
|
||||
result<int const&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
int x = 1;
|
||||
result<int const&, int> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
int const x = 1;
|
||||
result<int const&, int> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X const&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x( 1 );
|
||||
result<X const&> r( x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X const&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x( 1 );
|
||||
result<X const&> r = x;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X x( 1 );
|
||||
result<X const&, X> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r->v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
X const x( 1 );
|
||||
result<X const&, X> r( in_place_value, x );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r->v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int const&>, int&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<int&, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_constructible<result<int const&>, int const&>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_convertible<int const&, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<int const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<double const&>, int&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int&, result<double const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<double const&>, int const&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int const&, result<double const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<double const&>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<double const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, int>, int&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, float>, int&>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, int>, int const&>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, float>, int const&>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, int>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int const&, float>, int>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<X const&>, int>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<int, result<X const&>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<X const&>, X const>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<X const, result<X const&>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -2,6 +2,16 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 7
|
||||
# pragma GCC diagnostic ignored "-Wformat-truncation"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__has_warning)
|
||||
# if __has_warning( "-Wformat-truncation" )
|
||||
# pragma clang diagnostic ignored "-Wformat-truncation"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
|
@ -9,23 +9,6 @@
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout
|
||||
<< "The version of the C++ standard library being used does not"
|
||||
" support header <system_error> so interoperation will not be tested.\n";
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/snprintf.hpp>
|
||||
#include <system_error>
|
||||
@ -117,7 +100,7 @@ class user_category_impl: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
virtual const char * name() const noexcept
|
||||
{
|
||||
return "user";
|
||||
}
|
||||
@ -130,7 +113,7 @@ public:
|
||||
return buffer;
|
||||
}
|
||||
|
||||
virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
virtual boost::system::error_condition default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
if( ev == 4 )
|
||||
{
|
||||
@ -146,7 +129,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT
|
||||
virtual bool equivalent( int code, const boost::system::error_condition & condition ) const noexcept
|
||||
{
|
||||
if( code == 4 && condition == make_error_condition( boost::system::errc::too_many_files_open_in_system ) )
|
||||
{
|
||||
@ -161,7 +144,7 @@ public:
|
||||
return default_error_condition( code ) == condition;
|
||||
}
|
||||
|
||||
// virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
|
||||
// virtual bool equivalent( const error_code & code, int condition ) const noexcept;
|
||||
};
|
||||
|
||||
boost::system::error_category const & user_category()
|
||||
@ -257,7 +240,7 @@ class user2_category_impl: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
virtual const char * name() const noexcept
|
||||
{
|
||||
return "user2";
|
||||
}
|
||||
@ -270,17 +253,17 @@ public:
|
||||
return buffer;
|
||||
}
|
||||
|
||||
virtual boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
virtual boost::system::error_condition default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
return boost::system::error_condition( ev, *this );
|
||||
}
|
||||
|
||||
virtual bool equivalent( int code, const boost::system::error_condition & condition ) const BOOST_NOEXCEPT
|
||||
virtual bool equivalent( int code, const boost::system::error_condition & condition ) const noexcept
|
||||
{
|
||||
return default_error_condition( code ) == condition;
|
||||
}
|
||||
|
||||
virtual bool equivalent( const boost::system::error_code & code, int condition ) const BOOST_NOEXCEPT
|
||||
virtual bool equivalent( const boost::system::error_code & code, int condition ) const noexcept
|
||||
{
|
||||
if( code.category() == *this )
|
||||
{
|
||||
@ -337,9 +320,6 @@ static void test_user2_category()
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout
|
||||
<< "The version of the C++ standard library being used"
|
||||
" supports header <system_error> so interoperation will be tested.\n";
|
||||
test_generic_category();
|
||||
test_system_category();
|
||||
test_user_category();
|
||||
@ -347,5 +327,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4,16 +4,7 @@
|
||||
|
||||
#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()
|
||||
@ -62,5 +53,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -8,12 +8,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <ios>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined" )
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_LIBSTDCXX_VERSION < 50000" )
|
||||
int main() {}
|
||||
|
@ -6,17 +6,8 @@
|
||||
#include <boost/system/error_category.hpp>
|
||||
#include <boost/system/errc.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
|
||||
@ -28,12 +19,12 @@ class my_category: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
char const* name() const BOOST_NOEXCEPT
|
||||
char const* name() const noexcept
|
||||
{
|
||||
return "mycat";
|
||||
}
|
||||
|
||||
boost::system::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
boost::system::error_condition default_error_condition( int ev ) const noexcept
|
||||
{
|
||||
switch( ev )
|
||||
{
|
||||
@ -123,5 +114,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,24 +5,15 @@
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/error_category.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>
|
||||
|
||||
class my_category_impl: public std::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
char const* name() const BOOST_NOEXCEPT
|
||||
char const* name() const noexcept
|
||||
{
|
||||
return "mycat";
|
||||
}
|
||||
@ -73,5 +64,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -5,24 +5,15 @@
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/error_category.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>
|
||||
|
||||
class my_category_impl: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
char const* name() const BOOST_NOEXCEPT
|
||||
char const* name() const noexcept
|
||||
{
|
||||
return "mycat";
|
||||
}
|
||||
@ -53,5 +44,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -9,12 +9,7 @@
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
|
||||
#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY is defined" )
|
||||
int main() {}
|
||||
|
@ -3,15 +3,6 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_category.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#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 <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/snprintf.hpp>
|
||||
#include <system_error>
|
||||
@ -22,7 +13,7 @@ class user_category: public boost::system::error_category
|
||||
{
|
||||
public:
|
||||
|
||||
virtual const char * name() const BOOST_NOEXCEPT
|
||||
virtual const char * name() const noexcept
|
||||
{
|
||||
return "user";
|
||||
}
|
||||
@ -53,5 +44,3 @@ int main()
|
||||
BOOST_TEST_CSTR_EQ( cat.name(), "user" );
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -6,16 +6,7 @@
|
||||
#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 )
|
||||
@ -94,5 +85,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4,16 +4,7 @@
|
||||
|
||||
#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()
|
||||
@ -75,5 +66,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4,16 +4,7 @@
|
||||
|
||||
#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 )
|
||||
@ -85,5 +76,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4,16 +4,7 @@
|
||||
|
||||
#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()
|
||||
@ -104,5 +95,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -4,16 +4,7 @@
|
||||
|
||||
#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()
|
||||
@ -136,5 +127,3 @@ int main()
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user