Compare commits

..

52 Commits

Author SHA1 Message Date
Peter Dimov
1061db7dcd Update .drone.jsonnet 2025-11-02 20:08:38 +02:00
Peter Dimov
fa51e42fff Merge pull request #136 from vinniefalco/develop
chore: natvis uses correct layout for std::error_code
2025-11-02 20:04:15 +02:00
Vinnie Falco
323c618f99 chore: natvis uses correct layout for std::error_code
fix #135
2025-11-02 09:18:54 -08:00
Peter Dimov
1a3279d087 Update release notes for 1.89 (better late than never) 2025-10-29 15:44:52 +02:00
Peter Dimov
bd46fb21f3 Correct CMake version check; VERSION_GREATER 3.18 is true for 3.18.1 2025-10-19 21:04:45 +03:00
Peter Dimov
14c5f52602 Remove windows-2019 from ci.yml 2025-07-02 19:12:29 +03:00
Peter Dimov
7a495bb46d Switch Boost.System to header-only in b2 2025-06-26 16:37:21 +03:00
Peter Dimov
db00e1848e Update ci.yml 2025-06-26 15:59:21 +03:00
Peter Dimov
7a49a5d80d Change assertions in operator* to match documentation; improves codegen slightly in the result<U&> case 2025-02-24 19:46:43 +02:00
Peter Dimov
a0597f4872 Update .drone.jsonnet 2024-12-14 11:02:33 +02:00
Peter Dimov
485be93281 Apply Node20 workaround 2024-12-14 11:01:15 +02:00
Peter Dimov
ee0b15efc4 Update ci.yml 2024-12-14 11:00:28 +02:00
Peter Dimov
09f4eb87e2 Merge pull request #125 from igaztanaga/patch-1
Update system_category_message_win32.hpp
2024-09-05 21:25:41 +03:00
Peter Dimov
3e5ce27719 Add VERBATIM to add_custom_target 2024-08-28 03:02:08 +03:00
Peter Dimov
40bdcea2e5 Update build.jam, build/Jamfile, test/Jamfile 2024-08-28 02:10:03 +03:00
Rene Rivera
19bcfebf37 Sync from upstream. 2024-08-20 09:56:38 -05:00
Ion Gaztañaga
6d58d0bb76 Update system_category_message_win32.hpp
Fixes for Wsign-conversion with MinGW64 ("conversion to 'DWORD' {aka 'long unsigned int'} from 'int' may change the sign of the result")
2024-08-19 01:10:16 +02:00
Peter Dimov
a664cd1de6 Update .drone.jsonnet 2024-08-18 11:46:25 +03:00
Peter Dimov
e8a089b664 Update ci.yml 2024-08-17 18:22:21 +03:00
Rene Rivera
75e1a1e28b Update build deps. 2024-08-09 20:26:47 -05:00
Rene Rivera
5feb280612 Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:22 -05:00
Rene Rivera
fc3ab6db97 Update copyright dates. 2024-07-20 22:52:03 -05:00
Rene Rivera
91929719bd Change all <source> references to <library>. 2024-07-20 21:26:25 -05:00
Rene Rivera
8d0fa396b8 Bump B2 require to 5.2 2024-06-14 11:33:56 -05:00
Rene Rivera
671d0ad41b Sync from upstream. 2024-06-02 23:25:04 -05:00
Peter Dimov
5d5ecb74a7 Update .drone.jsonnet 2024-06-03 03:01:59 +03:00
Peter Dimov
41ff095c0a Try to fix the false positive with GCC ASAN 2024-06-03 02:40:13 +03:00
Peter Dimov
38d63aaf7c strerror_r(ev, tmp, 0) may return tmp 2024-06-02 23:03:24 +03:00
Peter Dimov
d1fb7554c5 Update error_code_test2, error_condition_test3 2024-06-02 22:41:48 +03:00
Peter Dimov
c63bca6eda Update error_condition_test3.cpp 2024-06-02 22:33:43 +03:00
Peter Dimov
bef2c5ef6a Update error_code_test2.cpp 2024-06-02 22:26:01 +03:00
Rene Rivera
341f960e72 Sync from upstream. 2024-06-02 13:49:02 -05:00
Mohammad Nejati
4d4f906548 strerror_r requires non-null buffer pointer
Fixes -Wnonnull warnings when calling message with a nullptr buffer
2024-06-02 18:21:07 +00:00
Mohammad Nejati
8a92683012 Add tests for calling message with nullptr buffer 2024-06-02 18:20:16 +00:00
Peter Dimov
be5a8ffa80 Disable -Wformat-truncation for Clang in snprintf_test 2024-06-02 19:45:18 +03:00
Peter Dimov
d032ab91fd Update ci.yml 2024-06-02 18:59:05 +03:00
Rene Rivera
9b82082f76 Add requires-b2 check to top-level build file. 2024-05-05 09:00:01 -05:00
Rene Rivera
3c293f8740 Add missing NO_LIB usage requirements. 2024-04-28 20:17:00 -05:00
Rene Rivera
2feb94ac07 Sync from upstream. 2024-04-20 15:31:42 -05:00
Peter Dimov
8f319f30c6 Update revision history 2024-04-17 03:41:33 +03:00
Rene Rivera
d09b2f5f1d Sync from upstream. 2024-04-10 07:55:53 -05:00
Peter Dimov
01d46f597e Update test/result_and_fn1v.cpp 2024-04-09 03:07:07 +03:00
Peter Dimov
93852d1a7e Support result<void> &= fv. Refs #119. 2024-04-09 03:01:38 +03:00
Peter Dimov
4aeebd2173 Avoid Appveyor timeout 2024-04-08 21:47:32 +03:00
Peter Dimov
96fef94580 Support result<void> & fv, where fv returns void. Refs #119. 2024-04-08 18:01:41 +03:00
Peter Dimov
75ab18c9fd Support result<X> & fv, where fv returns void. Refs #119. 2024-04-08 17:55:50 +03:00
Peter Dimov
f9a4655ae7 Merge pull request #120 from klemens-morgenstern/patch-1
declared global constants as inline with BOOST_INLINE_CONSTEXPR
2024-04-06 21:48:49 +03:00
Klemens Morgenstern
f6fcb1b690 declared global constants as inline with BOOST_INLINE_CONSTEXPR 2024-04-06 21:54:33 +08:00
Rene Rivera
27a5096b6c Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:15:59 -05:00
Rene Rivera
9cc66841c4 Make the library modular usable. 2024-03-11 08:38:16 -05:00
Peter Dimov
2fc720a1cb Update documentation 2024-02-03 04:07:53 +02:00
Peter Dimov
73de83b8f7 Update documentation 2024-02-02 08:28:41 +02:00
21 changed files with 842 additions and 202 deletions

View File

@@ -32,7 +32,8 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
commands:
[
'set -e',
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
'uname -a',
'echo $DRONE_STAGE_MACHINE',
] +
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
@@ -189,33 +190,68 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 22.04 GCC 12 32 ASAN",
"Linux 22.04 GCC 12 32",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '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: '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 23.04 GCC 13 32 UBSAN",
"cppalliance/droneubuntu2304:1",
"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 23.04 GCC 13 64 UBSAN",
"cppalliance/droneubuntu2304:1",
"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 25.04 GCC 15 UBSAN",
"cppalliance/droneubuntu2504:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
"g++-15-multilib",
),
linux_pipeline(
"Linux 25.04 GCC 15 ASAN",
"cppalliance/droneubuntu2504:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c' } + asan,
"g++-15-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
@@ -266,24 +302,59 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 23.04 Clang 16",
"cppalliance/droneubuntu2304:1",
"Linux 24.04 Clang 16",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
"clang-16",
),
linux_pipeline(
"Linux 23.10 Clang 17 UBSAN",
"cppalliance/droneubuntu2310:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
"clang-17",
),
linux_pipeline(
"Linux 23.10 Clang 17 ASAN",
"cppalliance/droneubuntu2310:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-17",
"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.04 Clang 19 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' } + ubsan,
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 19 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 20 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
"clang-20",
),
linux_pipeline(
"Linux 24.04 Clang 20 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + asan,
"clang-20",
),
macos_pipeline(

View File

@@ -19,38 +19,40 @@ jobs:
include:
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-4.8
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-8
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
- toolset: gcc-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: g++-10
- toolset: gcc-11
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-11
os: ubuntu-22.04
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
@@ -58,8 +60,18 @@ jobs:
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:23.04
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: gcc-15
cxxstd: "11,14,17,20,23,2c"
os: ubuntu-latest
container: ubuntu:25.04
install: g++-15
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
@@ -81,35 +93,45 @@ jobs:
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20"
os: ubuntu-20.04
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
@@ -131,40 +153,70 @@ jobs:
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
container: ubuntu:23.04
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,2b"
container: ubuntu:23.10
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
cxxstd: "11,14,17,2a"
os: macos-11
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
os: macos-12
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:25.04
os: ubuntu-latest
install: clang-20
- 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 python3 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
@@ -209,14 +261,6 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: "14"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
@@ -228,7 +272,7 @@ jobs:
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019
os: windows-2022
runs-on: ${{matrix.os}}
@@ -268,11 +312,11 @@ jobs:
fail-fast: false
matrix:
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}}
@@ -316,11 +360,11 @@ jobs:
fail-fast: false
matrix:
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}}
@@ -374,11 +418,11 @@ jobs:
fail-fast: false
matrix:
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}}
@@ -430,8 +474,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -479,8 +522,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -546,8 +588,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}

View File

@@ -22,7 +22,7 @@ target_link_libraries(boost_system
target_compile_features(boost_system INTERFACE cxx_std_11)
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
if(NOT CMAKE_VERSION VERSION_LESS 3.19 AND CMAKE_GENERATOR MATCHES "Visual Studio")
file(GLOB_RECURSE boost_system_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_system_IDEFILES} PREFIX "Header Files")

View File

@@ -17,7 +17,11 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17,latest
ADDRMD: 32,64
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

24
build.jam Normal file
View File

@@ -0,0 +1,24 @@
# 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 : : : : <include>include <library>$(boost_dependencies) ]
[ alias all : boost_system test ]
;
call-if : boost-library system
;

View File

@@ -1,25 +0,0 @@
# Boost System Library Build Jamfile
# (C) Copyright Beman Dawes 2002, 2006
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or 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)
<link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=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 ;

View File

@@ -8,12 +8,27 @@ https://www.boost.org/LICENSE_1_0.txt
# Revision History
:idprefix:
## Changes in Boost 1.89
* The stub compiled library has been removed; System has been header-only since release 1.69.
+
This may affect `CMakeLists.txt` files containing `find_package(Boost COMPONENTS system ...)`.
The easiest fix is to just remove `system` from the list of components as it's no longer required.
If compatibility with Boost releases earlier than 1.69 is to be preserved, one can use
`find_package(Boost COMPONENTS ... OPTIONAL_COMPONENTS system)`.
## 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

View File

@@ -2618,6 +2618,58 @@ int get_port()
}
```
#### 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&
```

View File

@@ -12,10 +12,10 @@
<Type Name="boost::system::error_code">
<DisplayString Condition="lc_flags_ == 0">{d1_.val_} [system] ✓</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==1">{((std::error_code*)d2_)->_Myval} [std:future]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==3">{((std::error_code*)d2_)->_Myval} [std:generic]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==5">{((std::error_code*)d2_)->_Myval} [std:iostream]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==7">{((std::error_code*)d2_)->_Myval} [std:system]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr._Num==1">{((std::error_code*)d2_)->_Myval} [std:future]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr._Num==3">{((std::error_code*)d2_)->_Myval} [std:generic]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr._Num==5">{((std::error_code*)d2_)->_Myval} [std:iostream]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr._Num==7">{((std::error_code*)d2_)->_Myval} [std:system]</DisplayString>
<DisplayString Condition="lc_flags_ == 1">{((std::error_code*)d2_)->_Myval} std@{((uintptr_t)((std::error_code*)d2_)->_Mycat),x}</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd0 &amp;&amp;

View File

@@ -39,7 +39,19 @@ inline char const * strerror_r_helper( int r, char const * buffer ) 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 )

View File

@@ -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;
}

View File

@@ -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>
@@ -838,11 +826,8 @@ public:
BOOST_CXX14_CONSTEXPR U& operator*() const noexcept
{
U* p = operator->();
BOOST_ASSERT( p != 0 );
return *p;
BOOST_ASSERT( has_value() );
return *operator->();
}
// error access
@@ -1124,7 +1109,8 @@ result<T, E>& operator|=( result<T, E>& r, F&& f )
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
class En = typename std::enable_if<!detail::is_result<U>::value>::type
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 )
{
@@ -1140,7 +1126,8 @@ result<U, E> operator&( result<T, E> const& r, F&& f )
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
class En = typename std::enable_if<!detail::is_result<U>::value>::type
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 )
{
@@ -1154,9 +1141,44 @@ result<U, E> operator&( result<T, E>&& r, F&& f )
}
}
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 En = typename std::enable_if<!detail::is_result<U>::value>::type
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 )
{
@@ -1170,6 +1192,23 @@ result<U, E> operator&( result<void, E> const& r, 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,
@@ -1242,6 +1281,20 @@ result<T, E>& operator&=( result<T, E>& r, F&& f )
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,

View File

@@ -1,31 +0,0 @@
// error_code stub implementation, for compatibility only
// Copyright Beman Dawes 2002, 2006
// Copyright Peter Dimov 2018
// 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
//----------------------------------------------------------------------------//
// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#define BOOST_SYSTEM_SOURCE
#include <boost/system/config.hpp>
namespace boost
{
namespace system
{
BOOST_SYSTEM_DECL void dummy_exported_function()
{
}
} // namespace system
} // namespace boost

View File

@@ -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

View File

@@ -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>)

View File

@@ -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>)

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -59,6 +59,13 @@ int& h( int& )
return x;
}
static int fv_called;
void fv()
{
++fv_called;
}
int main()
{
{
@@ -110,5 +117,25 @@ int main()
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();
}

View File

@@ -55,6 +55,20 @@ 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()
{
{
@@ -199,5 +213,119 @@ int main()
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();
}

View File

@@ -6,6 +6,12 @@
# 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>