Compare commits

...

36 Commits

Author SHA1 Message Date
Peter Dimov 3fe0eaec54 Disable result_error_construct_cx for Clang 5 and below 2026-02-16 02:28:56 +02:00
Peter Dimov 5fd72e7f0b Add test/result_error_construct_cx2 2026-02-16 02:21:46 +02:00
Peter Dimov 7a3a343189 Add test/result_value_construct_cx, test/result_error_construct_cx 2026-02-16 02:06:41 +02:00
Peter Dimov 7d36e164f2 Disable C++20 constexpr for Clang 10 2026-02-15 21:13:53 +02:00
Peter Dimov af53f17a27 Add constexpr to virtual functions on C++20 or later. Refs #141. 2026-02-15 19:28:43 +02:00
Peter Dimov 65983129dc Update .drone.jsonnet 2026-01-27 19:51:11 +02:00
Peter Dimov 2e1a6b58ba Add the Compat dependency to build.jam 2026-01-27 19:49:28 +02:00
Peter Dimov b7e9d0d737 Merge pull request #139 from Lastique/feature/remove_static_assert
Remove dependencies on Boost.StaticAssert
2026-01-23 02:29:59 +02:00
Andrey Semashev 1d00ab81c7 Remove dependencies on Boost.StaticAssert.
Boost.StaticAssert has been merged into Boost.Config, so replace
the dependency with Boost.Config.
2026-01-22 20:43:47 +03:00
Peter Dimov 423e6937ad Merge pull request #137 from corngood/cygwin
Use BOOST_POSIX_API on cygwin.
2025-12-18 19:30:01 +02:00
Peter Dimov b930bc38ac Update revision history 2025-12-18 19:28:55 +02:00
David McFarland d8b8483326 Use BOOST_POSIX_API on cygwin. 2025-12-18 10:04:35 -04:00
Peter Dimov 9529e070ea Still install boost_system, for the CMake configuration. Refs #132. 2025-12-15 21:52:49 +02:00
Peter Dimov 982abbe42a Remove local implementation of invoke; use Compat 2025-12-03 19:34:58 +02:00
Peter Dimov 56ba602d06 Test libc++ in ci.yml 2025-12-03 18:57:05 +02:00
Peter Dimov 7ec2584789 Enable pointers to members in r & f, where f returns result<> 2025-12-03 16:27:28 +02:00
Peter Dimov dec785741b Test const correctness of projection member functions in result_and_mfn1v.cpp 2025-12-03 16:06:50 +02:00
Peter Dimov c8e1b9fa0b Add data member pointer tests to result_and_mfn1v.cpp; decay return type of the projection when the lhs result is an rvalue 2025-12-03 15:42:21 +02:00
Peter Dimov 4d8f6f85cd Enable pointers to members in r & f, where f returns a value 2025-12-03 13:55:15 +02:00
Peter Dimov 05cb8f459c Update revision history 2025-12-03 13:13:40 +02:00
Peter Dimov 62878a6d06 Update documentation 2025-12-01 03:03:57 +02:00
Peter Dimov 8bb3ce6277 Decay return type of r | f when r is result<T&> and f() returns T. Refs #128. 2025-12-01 02:46:30 +02:00
Peter Dimov 1b74658f57 Decay return type of r | x when r is result<T&>. Refs #128. 2025-12-01 02:11:53 +02:00
Peter Dimov 6dc7819c2e Update ci.yml 2025-11-30 21:15:05 +02:00
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
28 changed files with 1305 additions and 294 deletions
+65 -11
View File
@@ -34,7 +34,6 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
'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 []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
@@ -205,22 +204,22 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
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 23.04 GCC 13 32 ASAN",
"cppalliance/droneubuntu2304:1",
"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",
),
@@ -239,6 +238,20 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"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",
@@ -289,15 +302,15 @@ 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",
"cppalliance/droneubuntu2310:1",
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
"clang-17",
),
@@ -316,6 +329,41 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"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",
),
linux_pipeline(
"Linux 25.10 Clang 21",
"cppalliance/droneubuntu2510:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '11,14,17,20,23,2c' },
"clang-21",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
@@ -361,4 +409,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2026 msvc-14.5",
"cppalliance/dronevs2026:1",
{ TOOLSET: 'msvc-14.5', CXXSTD: '14,17,20,latest' },
),
]
+111 -72
View File
@@ -19,33 +19,36 @@ 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"
@@ -56,129 +59,185 @@ jobs:
install: g++-12
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
container: ubuntu:23.04
install: g++-13
- toolset: gcc-14
cxxstd: "11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.04
os: ubuntu-latest
install: g++-14
- toolset: gcc-15
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:25.04
os: ubuntu-latest
install: g++-15
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
os: ubuntu-latest
install: clang-5.0
- 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
install: clang-7
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-7 libc++-7-dev libc++abi-7-dev
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-8
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-8 libc++-8-dev libc++abi-8-dev
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-9
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-9 libc++-9-dev libc++abi-9-dev
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10 libc++-10-dev libc++abi-10-dev
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11 libc++-11-dev libc++abi-11-dev
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20"
os: ubuntu-20.04
stdlib: "native,libc++"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12 libc++-12-dev libc++abi-12-dev
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
stdlib: "native,libc++"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
install: clang-13 libc++-13-dev libc++abi-13-dev
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
stdlib: "native,libc++"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
install: clang-14 libc++-14-dev libc++abi-14-dev
- toolset: clang
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
stdlib: "native,libc++"
os: ubuntu-latest
install: clang-15
install: clang-15 libc++-15-dev libc++abi-15-dev
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
container: ubuntu:23.04
stdlib: "native,libc++"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
install: clang-16 libc++-16-dev libc++abi-16-dev
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,2b"
container: ubuntu:23.10
stdlib: "native,libc++"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
install: clang-17 libc++-17-dev libc++abi-17-dev
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
stdlib: "native,libc++"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
install: clang-18 libc++-18-dev libc++abi-18-dev
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,2b"
os: macos-12
stdlib: "native,libc++"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-19 libc++-19-dev libc++abi-19-dev
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-13
compiler: clang++-20
cxxstd: "11,14,17,20,23,2c"
stdlib: "native,libc++"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-20 libc++-20-dev libc++abi-20-dev
- toolset: clang
compiler: clang++-21
cxxstd: "11,14,17,20,23,2c"
stdlib: "native,libc++"
container: ubuntu:25.10
os: ubuntu-latest
install: clang-21 libc++-21-dev libc++abi-21-dev
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-15
- toolset: clang
cxxstd: "11,14,17,20,23,2c"
os: macos-26
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:
- name: Enable Node 16
run: |
echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV
- 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
@@ -216,21 +275,13 @@ jobs:
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release ${{ matrix.stdlib && format('stdlib={0}', matrix.stdlib) }}
windows:
strategy:
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
@@ -242,7 +293,7 @@ jobs:
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019
os: windows-2022
runs-on: ${{matrix.os}}
@@ -282,11 +333,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -330,11 +378,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -388,11 +433,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-12
- os: macos-13
- os: macos-14
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{matrix.os}}
@@ -444,8 +486,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -493,8 +534,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
@@ -560,8 +600,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-latest
runs-on: ${{matrix.os}}
+3 -2
View File
@@ -2,7 +2,7 @@
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8...3.20)
cmake_minimum_required(VERSION 3.8...3.31)
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
@@ -14,6 +14,7 @@ target_include_directories(boost_system INTERFACE include)
target_link_libraries(boost_system
INTERFACE
Boost::assert
Boost::compat
Boost::config
Boost::throw_exception
Boost::variant2
@@ -22,7 +23,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")
+2 -1
View File
@@ -7,6 +7,7 @@ require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/compat//boost_compat
/boost/config//boost_config
/boost/throw_exception//boost_throw_exception
/boost/variant2//boost_variant2
@@ -16,7 +17,7 @@ constant boost_dependencies :
project /boost/system ;
explicit
[ alias boost_system : build//boost_system ]
[ alias boost_system : : : : <include>include <library>$(boost_dependencies) ]
[ alias all : boost_system test ]
;
-20
View File
@@ -1,20 +0,0 @@
# Boost System Library Build Jamfile
# Copyright 2002, 2006 Beman Dawes
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
# See library home page at https://www.boost.org/libs/system
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 : ../src/$(SOURCES).cpp ;
+18 -1
View File
@@ -1,5 +1,5 @@
////
Copyright 2018-2022 Peter Dimov
Copyright 2018-2025 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////
@@ -8,6 +8,23 @@ https://www.boost.org/LICENSE_1_0.txt
# Revision History
:idprefix:
## Changes in Boost 1.91
* The return type of `operator|(result<T&>, U)` has been changed to non-reference.
* Pointers to members in `r & f` are now supported (by using `boost::compat::invoke`).
* A CMake config file is now installed, even though the library is header-only. This
avoids breaking third-party `CMakeLists.txt` files that contain
`find_package(Boost COMPONENTS system ...)`.
## 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`.
+5 -4
View File
@@ -2518,8 +2518,8 @@ Returns: ::
#### 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 U> std::decay_t<T> operator|( result<T, E> const& r, U&& u );
template<class T, class E, class U> std::decay_t<T> operator|( result<T, E>&& r, U&& u );
```
[none]
* {blank}
@@ -2530,7 +2530,7 @@ Effects: ::
- If `r.has_value()` is `true`, returns `*r`.
- Otherwise, returns `u`.
Remarks: ::
Only enabled when `U` is convertible to `T`.
Only enabled when `U` is convertible to `std::decay_t<T>`.
Example: ::
+
```
@@ -2545,6 +2545,7 @@ int get_port()
```
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> std::decay_t<T> operator|( result<T&, E> const& r, F&& f );
```
[none]
* {blank}
@@ -2556,7 +2557,7 @@ Effects: ::
- If `r.has_value()` is `true`, returns `*r`.
- Otherwise, returns `f()`.
Remarks: ::
Only enabled when `f()` is convertible to `T`.
Only enabled when `f()` is convertible to `T`, or, when `T` is a reference, to `std::decay_t<T>`.
Example: ::
+
```
+4 -4
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;
+1 -1
View File
@@ -33,7 +33,7 @@
// Standalone MinGW and all other known Windows compilers do predefine _WIN32
// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too.
# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
# if defined(_WIN32) // Windows default, including MinGW
# define BOOST_WINDOWS_API
# else
# define BOOST_POSIX_API
+16
View File
@@ -38,6 +38,22 @@
# define BOOST_SYSTEM_CONSTEXPR
#endif
// BOOST_SYSTEM_HAS_CXX20_CONSTEXPR
#if defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
# define BOOST_SYSTEM_HAS_CXX20_CONSTEXPR
#endif
#if BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 110000)
# undef BOOST_SYSTEM_HAS_CXX20_CONSTEXPR
#endif
#if defined(BOOST_SYSTEM_HAS_CXX20_CONSTEXPR)
# define BOOST_SYSTEM_CXX20_CONSTEXPR constexpr
#else
# define BOOST_SYSTEM_CXX20_CONSTEXPR
#endif
// BOOST_SYSTEM_DEPRECATED
#if defined(__clang__)
+13 -13
View File
@@ -94,31 +94,31 @@ protected:
public:
virtual const char * name() const noexcept = 0;
virtual const char* name() const noexcept = 0;
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;
BOOST_SYSTEM_CXX20_CONSTEXPR virtual error_condition default_error_condition( int ev ) const noexcept;
BOOST_SYSTEM_CXX20_CONSTEXPR virtual bool equivalent( int code, error_condition const& condition ) const noexcept;
BOOST_SYSTEM_CXX20_CONSTEXPR virtual bool equivalent( error_code const& 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 noexcept;
virtual char const* message( int ev, char* buffer, std::size_t len ) const noexcept;
virtual bool failed( int ev ) const noexcept
BOOST_SYSTEM_CXX20_CONSTEXPR virtual bool failed( int ev ) const noexcept
{
return ev != 0;
}
friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) 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 ) 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 ) noexcept
friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const& lhs, error_category const& rhs ) noexcept
{
if( lhs.id_ < rhs.id_ )
{
@@ -135,15 +135,15 @@ public:
return false; // equal
}
return std::less<error_category const *>()( &lhs, &rhs );
return std::less<error_category const*>()( &lhs, &rhs );
}
void init_stdcat() const;
# if defined(__SUNPRO_CC) // trailing __global is not supported
operator std::error_category const & () const;
operator std::error_category const& () const;
# else
operator std::error_category const & () const BOOST_SYMBOL_VISIBLE;
operator std::error_category const& () const BOOST_SYMBOL_VISIBLE;
# endif
};
@@ -162,7 +162,7 @@ static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_ty
static const boost::ulong_long_type system_category_id = generic_category_id + 1;
static const boost::ulong_long_type interop_category_id = generic_category_id + 2;
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const& cat )
{
if( cat.id_ == system_category_id || cat.id_ == generic_category_id )
{
@@ -26,22 +26,22 @@ namespace system
// error_category default implementation
inline error_condition error_category::default_error_condition( int ev ) const noexcept
BOOST_SYSTEM_CXX20_CONSTEXPR 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 noexcept
BOOST_SYSTEM_CXX20_CONSTEXPR inline bool error_category::equivalent( int code, error_condition const& condition ) const noexcept
{
return default_error_condition( code ) == condition;
}
inline bool error_category::equivalent( const error_code & code, int condition ) const noexcept
BOOST_SYSTEM_CXX20_CONSTEXPR inline bool error_category::equivalent( error_code const& 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 noexcept
inline char const* error_category::message( int ev, char* buffer, std::size_t len ) const noexcept
{
if( len == 0 )
{
@@ -116,7 +116,7 @@ inline void error_category::init_stdcat() const
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
inline BOOST_NOINLINE error_category::operator std::error_category const & () const
inline BOOST_NOINLINE error_category::operator std::error_category const& () const
{
if( id_ == detail::generic_category_id )
{
+101 -42
View File
@@ -1,7 +1,7 @@
#ifndef BOOST_SYSTEM_RESULT_HPP_INCLUDED
#define BOOST_SYSTEM_RESULT_HPP_INCLUDED
// Copyright 2017, 2021, 2022 Peter Dimov.
// Copyright 2017, 2021-2025 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -10,6 +10,7 @@
#include <boost/system/detail/error_code.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#include <boost/variant2/variant.hpp>
#include <boost/compat/invoke.hpp>
#include <boost/throw_exception.hpp>
#include <boost/assert/source_location.hpp>
#include <boost/assert.hpp>
@@ -332,40 +333,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 +827,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
@@ -934,9 +920,10 @@ template<class T, class E> struct is_result< result<T, E> >: std::true_type {};
// result | value
template<class T, class E, class U,
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
class En = typename std::enable_if<std::is_convertible<U, typename std::decay<T>::type>::value>::type
>
T operator|( result<T, E> const& r, U&& u )
typename std::decay<T>::type
operator|( result<T, E> const& r, U&& u )
{
if( r )
{
@@ -949,9 +936,10 @@ T operator|( result<T, E> const& r, U&& u )
}
template<class T, class E, class U,
class En = typename std::enable_if<detail::is_value_convertible_to<U, T>::value>::type
class En = typename std::enable_if<std::is_convertible<U, typename std::decay<T>::type>::value>::type
>
T operator|( result<T, E>&& r, U&& u )
typename std::decay<T>::type
operator|( result<T, E>&& r, U&& u )
{
if( r )
{
@@ -997,6 +985,26 @@ T operator|( result<T, E>&& r, F&& f )
}
}
template<class T, class E, class F,
class U = decltype( std::declval<F>()() ),
class En = typename std::enable_if<
std::is_convertible<U, typename std::decay<T>::type>::value &&
!detail::is_value_convertible_to<U, T&>::value
>::type
>
typename std::decay<T>::type
operator|( result<T&, E> const& r, F&& f )
{
if( r )
{
return *r;
}
else
{
return std::forward<F>( f )();
}
}
// result | nullary-returning-result
template<class T, class E, class F,
@@ -1123,7 +1131,24 @@ result<T, E>& operator|=( result<T, E>& r, F&& f )
// result & unary-returning-value
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
class U = compat::invoke_result_t<F, 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 compat::invoke( std::forward<F>( f ), *r );
}
}
template<class T, class E, class F,
class U = compat::invoke_result_t<F, 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
>
@@ -1135,12 +1160,12 @@ result<U, E> operator&( result<T, E> const& r, F&& f )
}
else
{
return std::forward<F>( f )( *r );
return compat::invoke( std::forward<F>( f ), *r );
}
}
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
class U = typename std::decay< compat::invoke_result_t<F, T> >::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
>
@@ -1152,12 +1177,29 @@ result<U, E> operator&( result<T, E>&& r, F&& f )
}
else
{
return std::forward<F>( f )( *std::move( r ) );
return compat::invoke( 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 U = compat::invoke_result_t<F, 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 compat::invoke( std::forward<F>( f ), *std::move( r ) );
}
}
template<class T, class E, class F,
class U = compat::invoke_result_t<F, 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 )
@@ -1168,13 +1210,13 @@ result<U, E> operator&( result<T, E> const& r, F&& f )
}
else
{
std::forward<F>( f )( *r );
compat::invoke( std::forward<F>( f ), *r );
return {};
}
}
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
class U = compat::invoke_result_t<F, T>,
class En = typename std::enable_if<std::is_void<U>::value>::type
>
result<U, E> operator&( result<T, E>&& r, F&& f )
@@ -1185,7 +1227,7 @@ result<U, E> operator&( result<T, E>&& r, F&& f )
}
else
{
std::forward<F>( f )( *std::move( r ) );
compat::invoke( std::forward<F>( f ), *std::move( r ) );
return {};
}
}
@@ -1227,7 +1269,24 @@ result<U, E> operator&( result<void, E> const& r, F&& f )
// result & unary-returning-result
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T const&>() ) ),
class U = typename std::decay< compat::invoke_result_t<F, T&> >::type,
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 compat::invoke( std::forward<F>( f ), *r );
}
}
template<class T, class E, class F,
class U = typename std::decay< compat::invoke_result_t<F, T const&> >::type,
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
>
@@ -1239,12 +1298,12 @@ U operator&( result<T, E> const& r, F&& f )
}
else
{
return std::forward<F>( f )( *r );
return compat::invoke( std::forward<F>( f ), *r );
}
}
template<class T, class E, class F,
class U = decltype( std::declval<F>()( std::declval<T>() ) ),
class U = typename std::decay< compat::invoke_result_t<F, T> >::type,
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
>
@@ -1256,7 +1315,7 @@ U operator&( result<T, E>&& r, F&& f )
}
else
{
return std::forward<F>( f )( *std::move( r ) );
return compat::invoke( std::forward<F>( f ), *std::move( r ) );
}
}
-31
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
+10 -3
View File
@@ -27,7 +27,7 @@ macro(lib name macro)
endmacro()
set(BOOST_TEST_LINK_LIBRARIES Boost::system Boost::core Boost::static_assert)
set(BOOST_TEST_LINK_LIBRARIES Boost::system Boost::config Boost::core)
boost_test(SOURCES quick.cpp)
@@ -135,6 +135,8 @@ boost_test(TYPE run SOURCES ec_hash_value_test.cpp)
boost_test(TYPE run SOURCES std_interop_test16.cpp)
boost_test(TYPE run SOURCES failed_constexpr_test2.cpp)
# result
boost_test(TYPE run SOURCES result_default_construct.cpp)
@@ -165,8 +167,6 @@ 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)
@@ -177,3 +177,10 @@ 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)
boost_test(TYPE run SOURCES result_and_mfn1v.cpp)
boost_test(TYPE run SOURCES result_and_mfn1r.cpp)
boost_test(TYPE compile SOURCES result_value_construct_cx.cpp)
boost_test(TYPE compile SOURCES result_error_construct_cx.cpp)
boost_test(TYPE compile SOURCES result_error_construct_cx2.cpp)
+9 -2
View File
@@ -168,6 +168,8 @@ run ec_hash_value_test.cpp ;
run std_interop_test16.cpp ;
run failed_constexpr_test2.cpp ;
# result
run result_default_construct.cpp ;
@@ -198,8 +200,6 @@ 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 ;
@@ -210,3 +210,10 @@ run result_in_place_use.cpp ;
run result_or_eq_value.cpp ;
run result_or_eq_fn0v.cpp ;
run result_or_eq_fn0r.cpp ;
run result_and_mfn1v.cpp ;
run result_and_mfn1r.cpp ;
compile result_value_construct_cx.cpp ;
compile result_error_construct_cx.cpp ;
compile result_error_construct_cx2.cpp ;
+1 -1
View File
@@ -8,11 +8,11 @@ project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/system)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../compat boostorg/compat)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../core boostorg/core)
add_subdirectory(../../../mp11 boostorg/mp11)
add_subdirectory(../../../predef boostorg/predef)
add_subdirectory(../../../static_assert boostorg/static_assert)
add_subdirectory(../../../throw_exception boostorg/throw_exception)
add_subdirectory(../../../variant2 boostorg/variant2)
add_subdirectory(../../../winapi boostorg/winapi)
+54
View File
@@ -0,0 +1,54 @@
// Copyright 2026 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/system/error_condition.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#include <cstdio>
#if !defined(BOOST_SYSTEM_HAS_CXX20_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CXX20_CONSTEXPR isn't defined")
int main() {}
#else
namespace sys = boost::system;
class user_category: public sys::error_category
{
public:
constexpr virtual const char* name() const noexcept
{
return "user";
}
virtual std::string message( int ev ) const
{
char buffer[ 256 ];
std::snprintf( buffer, sizeof( buffer ), "user message %d", ev );
return buffer;
}
};
static constexpr user_category s_user_cat;
constexpr sys::error_code ec( 1, s_user_cat );
BOOST_STATIC_ASSERT( ec.failed() );
BOOST_STATIC_ASSERT( ec );
BOOST_STATIC_ASSERT( !!ec );
constexpr sys::error_condition en( 1, s_user_cat );
BOOST_STATIC_ASSERT( en.failed() );
BOOST_STATIC_ASSERT( en );
BOOST_STATIC_ASSERT( !!en );
int main() {}
#endif
+230
View File
@@ -0,0 +1,230 @@
// 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 E
{
};
struct E2
{
E2() {}
E2( E ) {}
};
struct X
{
int v_ = 0;
mutable int g_called_ = 0;
X( int v ): v_( v ) {}
result<int, E2> f() const { return v_; }
result<int, E2> f2() const { return E2(); }
result<int&, E2> g() { return v_; }
result<int const&, E2> g2() const { return v_; }
result<void, E2> h() const { return {}; }
result<void, E2> h2() const { return E2(); }
};
int main()
{
{
result<X, E> r( 1 );
{
result<int, E2> r2 = r & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<int, E2> r2 = r & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = r & &X::g;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
}
{
result<int const&, E2> r2 = r & &X::g2;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
}
{
result<void, E2> r2 = r & &X::h;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = r & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
{
result<X, E> const r( 1 );
{
result<int, E2> r2 = r & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<int, E2> r2 = r & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int const&, E2> r2 = r & &X::g2;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
}
{
result<void, E2> r2 = r & &X::h;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = r & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
{
{
result<int, E2> r2 = result<X, E>( 1 ) & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<int, E2> r2 = result<X, E>( 1 ) & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = result<X, E>( 1 ) & &X::g;
BOOST_TEST( r2.has_value() );
}
{
result<int const&, E2> r2 = result<X, E>( 1 ) & &X::g2;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = result<X, E>( 1 ) & &X::h;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = result<X, E>( 1 ) & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
{
result<X, E> r( in_place_error );
{
result<int, E2> r2 = r & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = r & &X::g;
BOOST_TEST( r2.has_error() );
}
{
result<int const&, E2> r2 = r & &X::g2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & &X::h;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
{
result<X, E> const r( in_place_error );
{
result<int, E2> r2 = r & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int const&, E2> r2 = r & &X::g2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & &X::h;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
{
{
result<int, E2> r2 = result<X, E>( in_place_error ) & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = result<X, E>( in_place_error ) & &X::f2;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = result<X, E>( in_place_error ) & &X::g;
BOOST_TEST( r2.has_error() );
}
{
result<int const&, E2> r2 = result<X, E>( in_place_error ) & &X::g2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<X, E>( in_place_error ) & &X::h;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<X, E>( in_place_error ) & &X::h2;
BOOST_TEST( r2.has_error() );
}
}
return boost::report_errors();
}
+254
View File
@@ -0,0 +1,254 @@
// 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_ = 0;
mutable int g_called_ = 0;
X( int v ): v_( v ) {}
int f() const { return v_; }
void g() const { ++g_called_; }
int& h() { return v_; }
int const& h2() const { return v_; }
};
struct E
{
};
int main()
{
{
result<X> r( 1 );
result<int> r2 = r & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<X> const r( 1 );
result<int> r2 = r & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<int> r2 = result<X>( 1 ) & &X::f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<X, E> r( in_place_error );
result<int, E> r2 = r & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<X, E> const r( in_place_error );
result<int, E> r2 = r & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> r2 = result<X, E>( in_place_error ) & &X::f;
BOOST_TEST( r2.has_error() );
}
{
result<X> r( 1 );
result<int&> r2 = r & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
}
{
result<X> const r( 1 );
result<int const&> r2 = r & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &r->v_ );
}
{
result<int> r2 = result<X>( 1 ) & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<X, E> r( in_place_error );
result<int&, E> r2 = r & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<X, E> const r( in_place_error );
result<int const&, E> r2 = r & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> r2 = result<X, E>( in_place_error ) & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
X x( 1 );
result<X&> r( x );
result<int&> r2 = r & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
}
{
X const x( 1 );
result<X const&> r( x );
result<int const&> r2 = r & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
}
{
X x( 1 );
result<int&> r2 = result<X&>( x ) & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
}
{
X const x( 1 );
result<int const&> r2 = result<X const&>( x ) & &X::v_;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x.v_ );
}
{
result<X&, E> r( in_place_error );
result<int&, E> r2 = r & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<X const&, E> const r( in_place_error );
result<int const&, E> r2 = r & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E> r2 = result<X&, E>( in_place_error ) & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<int const&, E> r2 = result<X const&, E>( in_place_error ) & &X::v_;
BOOST_TEST( r2.has_error() );
}
{
result<X> r( 1 );
result<void> r2 = r & &X::g;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( r->g_called_, 1 );
}
{
result<X> const r( 1 );
result<void> r2 = r & &X::g;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( r->g_called_, 1 );
}
{
result<void> r2 = result<X>( 1 ) & &X::g;
BOOST_TEST( r2.has_value() );
}
{
result<X, E> r( in_place_error );
result<void, E> r2 = r & &X::g;
BOOST_TEST( r2.has_error() );
}
{
result<X, E> const r( in_place_error );
result<void, E> r2 = r & &X::g;
BOOST_TEST( r2.has_error() );
}
{
result<void, E> r2 = result<X, E>( in_place_error ) & &X::g;
BOOST_TEST( r2.has_error() );
}
{
result<X> r( 1 );
result<int&> r2 = r & &X::h;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<X> const r( 1 );
result<int const&> r2 = r & &X::h2;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<int> r2 = result<X>( 1 ) & &X::h2;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 1 );
}
{
result<X, E> r( in_place_error );
result<int&, E> r2 = r & &X::h;
BOOST_TEST( r2.has_error() );
}
{
result<X, E> const r( in_place_error );
result<int const&, E> r2 = r & &X::h2;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> r2 = result<X, E>( in_place_error ) & &X::h2;
BOOST_TEST( r2.has_error() );
}
return boost::report_errors();
}
+96
View File
@@ -0,0 +1,96 @@
// Copyright 2017, 2021, 2026 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/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
#elif defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 60000
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_CLANG_VERSION < 60000")
#else
using namespace boost::system;
int main()
{
{
constexpr auto ec = make_error_code( errc::invalid_argument );
constexpr result<int> r( ec );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == ec );
}
{
constexpr result<int> r( EINVAL, generic_category() );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( EINVAL, generic_category() ) );
}
{
constexpr auto ec = make_error_code( errc::invalid_argument );
constexpr result<error_code> r( in_place_error, ec );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == ec );
}
{
constexpr result<error_code> r( in_place_error, EINVAL, generic_category() );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( EINVAL, generic_category() ) );
}
{
constexpr auto ec = make_error_code( errc::invalid_argument );
constexpr result<void> r( ec );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == ec );
}
{
constexpr auto ec = make_error_code( errc::invalid_argument );
constexpr result<void> r = ec;
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == ec );
}
{
constexpr result<void> r( EINVAL, generic_category() );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( EINVAL, generic_category() ) );
}
}
#endif
+77
View File
@@ -0,0 +1,77 @@
// Copyright 2017, 2021, 2026 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/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#include <cstdio>
#if !defined(BOOST_SYSTEM_HAS_CXX20_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CXX20_CONSTEXPR isn't defined")
#else
using namespace boost::system;
class user_category: public error_category
{
public:
constexpr virtual const char* name() const noexcept
{
return "user";
}
virtual std::string message( int ev ) const
{
char buffer[ 256 ];
std::snprintf( buffer, sizeof( buffer ), "user message %d", ev );
return buffer;
}
};
static constexpr user_category s_user_cat;
int main()
{
{
constexpr result<int> r( 1, s_user_cat );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( 1, s_user_cat ) );
}
{
constexpr result<error_code> r( in_place_error, 2, s_user_cat );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( 2, s_user_cat ) );
}
{
constexpr result<void> r( 3, s_user_cat );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( 3, s_user_cat ) );
}
{
constexpr result<void> r( in_place_error, 4, s_user_cat );
BOOST_STATIC_ASSERT( !r.has_value() );
BOOST_STATIC_ASSERT( r.has_error() );
BOOST_STATIC_ASSERT( r.error() == error_code( 4, s_user_cat ) );
}
}
#endif
+24 -42
View File
@@ -191,120 +191,102 @@ int main()
{
int x1 = 1;
int x3 = 3;
result<int&> r( x1 );
int& x = r | fri | x3;
auto r2 = r | fri;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x1 = 1;
int x3 = 3;
result<int&> const r( x1 );
int& x = r | fri | x3;
auto r2 = r | fri;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x1 = 1;
int x3 = 3;
int& x = result<int&>( x1 ) | fri | x3;
auto r2 = result<int&>( x1 ) | fri;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x1 = 1;
int x3 = 3;
result<int&> r( x1 );
int& x = r | fri2 | x3;
auto r2 = r | fri2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x1 = 1;
int x3 = 3;
result<int&> const r( x1 );
int& x = r | fri2 | x3;
auto r2 = r | fri2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x1 = 1;
int x3 = 3;
int& x = result<int&>( x1 ) | fri2 | x3;
auto r2 = result<int&>( x1 ) | fri2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &x1 );
}
{
int x3 = 3;
result<int&, E> r( in_place_error );
int& x = r | fri | x3;
auto r2 = r | fri;
BOOST_TEST_EQ( &x, &*fri() );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
}
{
int x3 = 3;
result<int&, E> const r( in_place_error );
int& x = r | fri | x3;
auto r2 = r | fri;
BOOST_TEST_EQ( &x, &*fri() );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
}
{
int x3 = 3;
auto r2 = result<int&, E>( in_place_error ) | fri;
int& x = result<int&, E>( in_place_error ) | fri | x3;
BOOST_TEST_EQ( &x, &*fri() );
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &*fri() );
}
{
int x3 = 3;
result<int&, E> r( in_place_error );
int& x = r | fri2 | x3;
auto r2 = r | fri2;
BOOST_TEST_EQ( &x, &x3 );
BOOST_TEST( r2.has_error() );
}
{
int x3 = 3;
result<int&, E> const r( in_place_error );
int& x = r | fri2 | x3;
auto r2 = r | fri2;
BOOST_TEST_EQ( &x, &x3 );
BOOST_TEST( r2.has_error() );
}
{
int x3 = 3;
auto r2 = result<int&, E>( in_place_error ) | fri2;
int& x = result<int&, E>( in_place_error ) | fri2 | x3;
BOOST_TEST_EQ( &x, &x3 );
BOOST_TEST( r2.has_error() );
}
{
+67
View File
@@ -4,6 +4,8 @@
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
using namespace boost::system;
@@ -108,6 +110,71 @@ int main()
BOOST_TEST_EQ( y.v_, 2 );
}
{
int x1 = 1;
result<int&> r( x1 );
auto&& x2 = r | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, x1 );
BOOST_TEST_NE( &x2, &x1 );
}
{
int x1 = 1;
result<int&> const r( x1 );
auto&& x2 = r | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, x1 );
BOOST_TEST_NE( &x2, &x1 );
}
{
int x1 = 1;
auto&& x2 = result<int&>( x1 ) | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, x1 );
BOOST_TEST_NE( &x2, &x1 );
}
{
result<int&, E> r( in_place_error );
auto&& x2 = r | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, f() );
}
{
result<int&, E> const r( in_place_error );
auto&& x2 = r | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, f() );
}
{
auto&& x2 = result<int&, E>( in_place_error ) | f;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x2)> ));
BOOST_TEST_EQ( x2, f() );
}
{
int x1 = 1;
+92 -12
View File
@@ -4,6 +4,8 @@
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <type_traits>
using namespace boost::system;
@@ -110,9 +112,22 @@ int main()
result<int&> r( x1 );
int& x = r | x2;
{
auto&& x3 = r | x2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x1 );
BOOST_TEST_NE( &x3, &x1 );
}
{
auto&& x4 = r | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, x1 );
}
}
{
@@ -121,18 +136,44 @@ int main()
result<int&> const r( x1 );
int& x = r | x2;
{
auto&& x3 = r | x2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x1 );
BOOST_TEST_NE( &x3, &x1 );
}
{
auto&& x4 = r | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, x1 );
}
}
{
int x1 = 1;
int x2 = 2;
int& x = result<int&>( x1 ) | x2;
{
auto&& x3 = result<int&>( x1 ) | x2;
BOOST_TEST_EQ( &x, &x1 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x1 );
BOOST_TEST_NE( &x3, &x1 );
}
{
auto&& x4 = result<int&>( x1 ) | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, x1 );
}
}
{
@@ -140,9 +181,22 @@ int main()
result<int&, E> r( in_place_error );
int& x = r | x2;
{
auto&& x3 = r | x2;
BOOST_TEST_EQ( &x, &x2 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x2 );
BOOST_TEST_NE( &x3, &x2 );
}
{
auto&& x4 = r | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, 3 );
}
}
{
@@ -150,17 +204,43 @@ int main()
result<int&, E> const r( in_place_error );
int& x = r | x2;
{
auto&& x3 = r | x2;
BOOST_TEST_EQ( &x, &x2 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x2 );
BOOST_TEST_NE( &x3, &x2 );
}
{
auto&& x4 = r | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, 3 );
}
}
{
int x2 = 2;
int& x = result<int&, E>( in_place_error ) | x2;
{
auto&& x3 = result<int&, E>( in_place_error ) | x2;
BOOST_TEST_EQ( &x, &x2 );
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype(x3)> ));
BOOST_TEST_EQ( x3, x2 );
BOOST_TEST_NE( &x3, &x2 );
}
{
auto&& x4 = result<int&, E>( in_place_error ) | 3;
BOOST_TEST_TRAIT_FALSE(( std::is_lvalue_reference<decltype( x4 )> ));
BOOST_TEST_EQ( x4, 3 );
}
}
return boost::report_errors();
-14
View File
@@ -1,14 +0,0 @@
// 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
View File
@@ -1,13 +0,0 @@
// 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;
}
+47
View File
@@ -0,0 +1,47 @@
// Copyright 2017, 2021, 2026 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/config/pragma_message.hpp>
#include <boost/static_assert.hpp>
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Skipping constexpr test, BOOST_SYSTEM_HAS_CONSTEXPR isn't defined")
#else
using namespace boost::system;
int main()
{
{
constexpr result<int> r( 0 );
BOOST_STATIC_ASSERT( r.has_value() );
BOOST_STATIC_ASSERT( !r.has_error() );
BOOST_STATIC_ASSERT( r.value() == 0 );
BOOST_STATIC_ASSERT( *r == 0 );
}
{
constexpr result<int> r( in_place_value, 1 );
BOOST_STATIC_ASSERT( r.has_value() );
BOOST_STATIC_ASSERT( !r.has_error() );
BOOST_STATIC_ASSERT( r.value() == 1 );
BOOST_STATIC_ASSERT( *r == 1 );
}
{
constexpr result<void> r( in_place_value );
BOOST_STATIC_ASSERT( r.has_value() );
BOOST_STATIC_ASSERT( !r.has_error() );
}
}
#endif