forked from boostorg/system
Compare commits
49 Commits
esp-idf-co
...
feature/de
Author | SHA1 | Date | |
---|---|---|---|
3e6af15652 | |||
bb60a27b18 | |||
e478ba1a2b | |||
50100b0e81 | |||
bb502f5d67 | |||
fa2349eee7 | |||
3d9acaf082 | |||
c6795eb9d0 | |||
57c295bbf7 | |||
36e3b2c6ae | |||
583cd8dba2 | |||
0c2de4cb2a | |||
3d595a6e79 | |||
b3faedfe3e | |||
32bf67f748 | |||
5d15aa1267 | |||
36e1236a0f | |||
2c20b6e7e5 | |||
103f3b4f00 | |||
14f779e234 | |||
bfccd4b4d9 | |||
7ae6b317f3 | |||
9a6d79b841 | |||
ece71199a9 | |||
1e4c050d6c | |||
21115121bb | |||
956fa92a53 | |||
ee318f937f | |||
19f99264de | |||
3261bae6de | |||
20ce51858b | |||
52d7429473 | |||
53c00841fc | |||
19e27a73e9 | |||
19020ce925 | |||
3faf415026 | |||
a2df4d09da | |||
455c6a6332 | |||
efb7634666 | |||
2bba3fd5e2 | |||
8c740705e6 | |||
4708d95e80 | |||
867f6d06d0 | |||
ac1ed1ecc1 | |||
fe48c3058d | |||
cc7c2f7ee4 | |||
f2e1db8021 | |||
ede243c42f | |||
1558aaa789 |
@ -173,48 +173,114 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 9 ARM64 32/64",
|
||||
"Linux 20.04 GCC 9* ARM64",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||
arch="arm64",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32 ASAN",
|
||||
"Linux 20.04 GCC 9* S390x",
|
||||
"cppalliance/droneubuntu2004:multiarch",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
|
||||
arch="s390x",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 32",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 GCC 10 64 ASAN",
|
||||
"Linux 20.04 GCC 10 64",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' } + asan,
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '64' },
|
||||
"g++-10-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 13",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
"Linux 22.04 GCC 11* 32",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 11* 64",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '64' },
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 32 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 GCC 12 64 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
|
||||
"g++-12-multilib",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.5",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
|
||||
"clang-3.5",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.6",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
|
||||
"clang-3.6",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.7",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
|
||||
"clang-3.7",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 16.04 Clang 3.8",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
|
||||
"clang-3.8",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 13",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
|
||||
"clang-13",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 UBSAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
"Linux 22.04 Clang 14 UBSAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + ubsan,
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 20.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2004:1",
|
||||
"Linux 22.04 Clang 14 ASAN",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' } + asan,
|
||||
"clang-14",
|
||||
["deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main"],
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 22.04 Clang 15",
|
||||
"cppalliance/droneubuntu2204:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
|
||||
"clang-15",
|
||||
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"],
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
|
79
.github/workflows/ci.yml
vendored
79
.github/workflows/ci.yml
vendored
@ -19,22 +19,26 @@ jobs:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-4.8
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-5
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: g++-6
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: g++-8
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
@ -48,33 +52,36 @@ jobs:
|
||||
os: ubuntu-20.04
|
||||
install: g++-11
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
os: ubuntu-20.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
@ -100,26 +107,40 @@ jobs:
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20"
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-22.04
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
os: macos-11
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-12
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python git g++
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -182,7 +203,7 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
@ -217,19 +238,19 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -264,19 +285,19 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
@ -321,19 +342,19 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
- os: macos-12
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
|
@ -2,7 +2,7 @@
|
||||
# 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
|
||||
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
cmake_minimum_required(VERSION 3.5...3.20)
|
||||
|
||||
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
@ -20,6 +20,15 @@ target_link_libraries(boost_system
|
||||
Boost::winapi
|
||||
)
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.18 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")
|
||||
list(APPEND boost_system_IDEFILES extra/boost_system.natvis)
|
||||
target_sources(boost_system PRIVATE ${boost_system_IDEFILES})
|
||||
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
31
appveyor.yml
31
appveyor.yml
@ -40,6 +40,12 @@ environment:
|
||||
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_SUBDIR: 1
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
CMAKE_INSTALL: 1
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
@ -59,4 +65,27 @@ test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
- if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
|
||||
- if not "%CMAKE%" == "" mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=system -DBoost_VERBOSE=ON ..
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Debug & ctest --output-on-failure --no-tests=error -j 3 -C Debug
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Release & ctest --output-on-failure --no-tests=error -j 3 -C Release
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config MinSizeRel & ctest --output-on-failure --no-tests=error -j 3 -C MinSizeRel
|
||||
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -j 3 -C RelWithDebInfo
|
||||
|
||||
- if not "%CMAKE_SUBDIR%" == "" cd libs/system/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake ..
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config MinSizeRel && cmake --build . --target check --config MinSizeRel
|
||||
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config RelWithDebInfo && cmake --build . --target check --config RelWithDebInfo
|
||||
|
||||
- if not "%CMAKE_INSTALL%" == "" mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake -DBOOST_INCLUDE_LIBRARIES=system -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Debug
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Release
|
||||
- if not "%CMAKE_INSTALL%" == "" cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
|
||||
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
|
||||
|
@ -8,6 +8,14 @@ https://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.81
|
||||
|
||||
* The macro `BOOST_SYSTEM_DISABLE_THREADS` can now be defined to disable
|
||||
the use of `<mutex>` (e.g. on single-threaded libstdc++).
|
||||
* Added `value_type`, `error_type`, `in_place_value`, `in_place_error`
|
||||
to `result<>`.
|
||||
* Added `emplace` to `result<>`.
|
||||
|
||||
## Changes in Boost 1.80
|
||||
|
||||
* When an `error_code` is converted to `std::error_code` and then back
|
||||
|
@ -29,6 +29,11 @@ When `BOOST_SYSTEM_USE_UTF8` is defined, on Windows the library returns
|
||||
UTF-8 messages using code page `CP_UTF8` instead of the default `CP_ACP`.
|
||||
This macro has no effect on POSIX.
|
||||
|
||||
When `BOOST_SYSTEM_DISABLE_THREADS` is defined, the library assumes that
|
||||
the current platform doesn't support multiple threads and disables the use
|
||||
of the standard header `<mutex>`, eliminating the mutex locks. The single
|
||||
threaded `libstdc++` is one such platform.
|
||||
|
||||
## Deprecated Names
|
||||
|
||||
In the process of adding Boost.System to the {cpp}11 standard library, the
|
||||
@ -1595,6 +1600,12 @@ template<class T, class E = error_code> class result
|
||||
{
|
||||
public:
|
||||
|
||||
using value_type = T;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
// constructors
|
||||
|
||||
constexpr result();
|
||||
@ -1648,6 +1659,11 @@ public:
|
||||
|
||||
constexpr E error() const;
|
||||
|
||||
// emplace
|
||||
|
||||
template<class... A>
|
||||
constexpr T& emplace( A&&... a );
|
||||
|
||||
// swap
|
||||
|
||||
constexpr void swap( result& r );
|
||||
@ -1843,6 +1859,20 @@ constexpr E error() const;
|
||||
Effects: ::
|
||||
If `*this` holds an error, returns it. Otherwise, returns `E()`.
|
||||
|
||||
#### emplace
|
||||
|
||||
```
|
||||
template<class... A>
|
||||
constexpr T& emplace( A&&... a );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds the value `T( std::forward<A>(a)... )`.
|
||||
Returns: ::
|
||||
A reference to the contained value.
|
||||
|
||||
#### swap
|
||||
|
||||
```
|
||||
@ -1911,6 +1941,12 @@ template<class E> class result<void, E>
|
||||
{
|
||||
public:
|
||||
|
||||
using value_type = void;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
// constructors
|
||||
|
||||
constexpr result() noexcept;
|
||||
@ -1945,6 +1981,10 @@ public:
|
||||
|
||||
constexpr E error() const;
|
||||
|
||||
// emplace
|
||||
|
||||
constexpr void emplace();
|
||||
|
||||
// swap
|
||||
|
||||
constexpr void swap( result& r );
|
||||
@ -2088,6 +2128,17 @@ constexpr E error() const;
|
||||
Effects: ::
|
||||
If `*this` holds an error, returns it. Otherwise, returns `E()`.
|
||||
|
||||
#### emplace
|
||||
|
||||
```
|
||||
constexpr void emplace();
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Ensures: ::
|
||||
`*this` holds an unspecified value.
|
||||
|
||||
#### swap
|
||||
|
||||
```
|
||||
|
53
extra/boost_system.natvis
Normal file
53
extra/boost_system.natvis
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
|
||||
|
||||
<Type Name="boost::system::error_category">
|
||||
<DisplayString Condition="id_ == 0xb2ab117a257edfd0">[generic]</DisplayString>
|
||||
<DisplayString Condition="id_ == 0xb2ab117a257edfd1">[system]</DisplayString>
|
||||
<DisplayString Condition="id_ == 0xb2ab117a257edfd2">[interop]</DisplayString>
|
||||
<DisplayString Condition="id_ != 0">[{id_,x}]</DisplayString>
|
||||
<DisplayString>@{((uintptr_t)this),x}</DisplayString>
|
||||
</Type>
|
||||
|
||||
<Type Name="boost::system::error_code">
|
||||
<DisplayString Condition="lc_flags_ == 0">{d1_.val_} [system] ✓</DisplayString>
|
||||
|
||||
<DisplayString Condition="lc_flags_ == 1 && ((std::error_code*)d2_)->_Mycat->_Addr==1">{((std::error_code*)d2_)->_Myval} [std:future]</DisplayString>
|
||||
<DisplayString Condition="lc_flags_ == 1 && ((std::error_code*)d2_)->_Mycat->_Addr==3">{((std::error_code*)d2_)->_Myval} [std:generic]</DisplayString>
|
||||
<DisplayString Condition="lc_flags_ == 1 && ((std::error_code*)d2_)->_Mycat->_Addr==5">{((std::error_code*)d2_)->_Myval} [std:iostream]</DisplayString>
|
||||
<DisplayString Condition="lc_flags_ == 1 && ((std::error_code*)d2_)->_Mycat->_Addr==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 &&
|
||||
(lc_flags_ == 2 || (lc_flags_ > 3 && ( lc_flags_ % 2 == 0 )))">{d1_.val_} [generic] ✓</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd1 &&
|
||||
(lc_flags_ == 2 || (lc_flags_ > 3 && ( lc_flags_ % 2 == 0 )))">{d1_.val_} [system] ✓</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd2 &&
|
||||
(lc_flags_ == 2 || (lc_flags_ > 3 && ( lc_flags_ % 2 == 0 )))">{d1_.val_} [interop] ✓</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ != 0 &&
|
||||
(lc_flags_ == 2 || (lc_flags_ > 3 && ( lc_flags_ % 2 == 0 )))">{d1_.val_} [{d1_.cat_->id_,x}] ✓</DisplayString>
|
||||
<DisplayString Condition=
|
||||
"lc_flags_ == 2 || (lc_flags_ > 3 && ( lc_flags_ % 2 == 0 ))">{d1_.val_} @{((uintptr_t)d1_.cat_),x} ✓</DisplayString>
|
||||
|
||||
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd0 &&
|
||||
(lc_flags_ >= 3 && ( lc_flags_ % 2 == 1 ))">{d1_.val_} [generic]</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd1 &&
|
||||
(lc_flags_ >= 3 && ( lc_flags_ % 2 == 1 ))">{d1_.val_} [system]</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd2 &&
|
||||
(lc_flags_ >= 3 && ( lc_flags_ % 2 == 1 ))">{d1_.val_} [interop]</DisplayString>
|
||||
<DisplayString Condition="d1_.cat_->id_ != 0 &&
|
||||
(lc_flags_ >= 3 && ( lc_flags_ % 2 == 1 ))">{d1_.val_} [{d1_.cat_->id_,x}]</DisplayString>
|
||||
<DisplayString Condition=
|
||||
"lc_flags_ >= 3 && ( lc_flags_ % 2 == 1 )">{d1_.val_} @{((uintptr_t)d1_.cat_),x}</DisplayString>
|
||||
|
||||
<Expand>
|
||||
<Item Name="std::error_code" Condition="lc_flags_ == 1">(std::error_code*)d2_</Item>
|
||||
<Item Name="[location]" Condition="lc_flags_ > 3">*((boost::source_location*)(lc_flags_ & ~1))</Item>
|
||||
</Expand>
|
||||
</Type>
|
||||
|
||||
<Type Name="boost::system::result<*,*>">
|
||||
<DisplayString>{v_}</DisplayString>
|
||||
</Type>
|
||||
|
||||
</AutoVisualizer>
|
@ -12,8 +12,14 @@
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
// BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
//
|
||||
// The macro BOOST_SYSTEM_DISABLE_THREADS can be defined on configurations
|
||||
// that provide <system_error> and <atomic>, but not <mutex>, such as the
|
||||
// single-threaded libstdc++.
|
||||
//
|
||||
// https://github.com/boostorg/system/issues/92
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC) && !defined(BOOST_NO_CXX11_HDR_MUTEX)
|
||||
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR) && !defined(BOOST_NO_CXX11_HDR_ATOMIC) && ( !defined(BOOST_NO_CXX11_HDR_MUTEX) || defined(BOOST_SYSTEM_DISABLE_THREADS) )
|
||||
# define BOOST_SYSTEM_HAS_SYSTEM_ERROR
|
||||
#endif
|
||||
|
||||
@ -58,7 +64,9 @@
|
||||
|
||||
// BOOST_SYSTEM_CLANG_6
|
||||
|
||||
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11))
|
||||
// Android NDK r18b has Clang 7.0.2 that still needs the workaround
|
||||
// https://github.com/boostorg/system/issues/100
|
||||
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11) || (defined(__ANDROID__) && __clang_major__ == 7))
|
||||
# define BOOST_SYSTEM_CLANG_6
|
||||
#endif
|
||||
|
||||
|
@ -48,7 +48,7 @@ class std_category;
|
||||
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4351) // new behavior: elements of array will be default initialized
|
||||
#endif
|
||||
@ -183,7 +183,7 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
@ -98,7 +98,7 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
#include <boost/system/detail/std_category_impl.hpp>
|
||||
#include <mutex>
|
||||
#include <boost/system/detail/mutex.hpp>
|
||||
#include <new>
|
||||
|
||||
namespace boost
|
||||
@ -111,10 +111,10 @@ namespace detail
|
||||
|
||||
template<class = void> struct stdcat_mx_holder
|
||||
{
|
||||
static std::mutex mx_;
|
||||
static mutex mx_;
|
||||
};
|
||||
|
||||
template<class T> std::mutex stdcat_mx_holder<T>::mx_;
|
||||
template<class T> mutex stdcat_mx_holder<T>::mx_;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@ -130,11 +130,11 @@ inline void error_category::init_stdcat() const
|
||||
|
||||
#endif
|
||||
|
||||
std::lock_guard<std::mutex> lk( boost::system::detail::stdcat_mx_holder<>::mx_ );
|
||||
system::detail::lock_guard<system::detail::mutex> lk( system::detail::stdcat_mx_holder<>::mx_ );
|
||||
|
||||
if( sc_init_.load( std::memory_order_acquire ) == 0 )
|
||||
{
|
||||
::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, 0 );
|
||||
::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, system::detail::id_wrapper<0>() );
|
||||
sc_init_.store( 1, std::memory_order_release );
|
||||
}
|
||||
}
|
||||
@ -151,7 +151,7 @@ inline BOOST_NOINLINE error_category::operator std::error_category const & () co
|
||||
// This condition must be the same as the one in error_condition.hpp
|
||||
#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
|
||||
|
||||
static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 );
|
||||
static const boost::system::detail::std_category generic_instance( this, system::detail::id_wrapper<0x1F4D3>() );
|
||||
return generic_instance;
|
||||
|
||||
#else
|
||||
@ -166,7 +166,7 @@ inline BOOST_NOINLINE error_category::operator std::error_category const & () co
|
||||
// This condition must be the same as the one in error_code.hpp
|
||||
#if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY)
|
||||
|
||||
static const boost::system::detail::std_category system_instance( this, 0x1F4D7 );
|
||||
static const boost::system::detail::std_category system_instance( this, system::detail::id_wrapper<0x1F4D7>() );
|
||||
return system_instance;
|
||||
|
||||
#else
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <boost/assert/source_location.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
#include <cstdio>
|
||||
@ -57,12 +58,14 @@ namespace system
|
||||
// and error_code containing a pointer to an object of a type derived
|
||||
// from error_category.
|
||||
|
||||
bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT;
|
||||
std::size_t hash_value( error_code const & ec );
|
||||
|
||||
class error_code
|
||||
{
|
||||
private:
|
||||
|
||||
friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT;
|
||||
friend std::size_t hash_value( error_code const & ec );
|
||||
|
||||
private:
|
||||
@ -114,7 +117,10 @@ public:
|
||||
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40800)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
error_code() BOOST_NOEXCEPT:
|
||||
d1_(), lc_flags_( 0 )
|
||||
{
|
||||
}
|
||||
@ -397,7 +403,12 @@ public:
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
if( s1 != s2 ) return false;
|
||||
|
||||
if( s1 && s2 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
@ -415,7 +426,13 @@ public:
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
if( s1 < s2 ) return true;
|
||||
if( s2 < s1 ) return false;
|
||||
|
||||
if( s1 && s2 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
@ -434,48 +451,6 @@ public:
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.lc_flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.lc_flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
@ -678,6 +653,37 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.lc_flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
{
|
||||
return code == condition;
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline std::size_t hash_value( error_code const & ec )
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
@ -261,6 +261,58 @@ public:
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_condition( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_condition( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator==( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_code( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator==( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_code( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator!=( error_condition const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
inline friend bool operator!=( E lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
std::string to_string() const
|
||||
|
88
include/boost/system/detail/mutex.hpp
Normal file
88
include/boost/system/detail/mutex.hpp
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_SYSTEM_DISABLE_THREADS)
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct mutex
|
||||
{
|
||||
void lock()
|
||||
{
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#else
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
using std::mutex;
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class Mtx> class lock_guard
|
||||
{
|
||||
private:
|
||||
|
||||
Mtx& mtx_;
|
||||
|
||||
private:
|
||||
|
||||
lock_guard( lock_guard const& );
|
||||
lock_guard& operator=( lock_guard const& );
|
||||
|
||||
public:
|
||||
|
||||
explicit lock_guard( Mtx& mtx ): mtx_( mtx )
|
||||
{
|
||||
mtx_.lock();
|
||||
}
|
||||
|
||||
~lock_guard()
|
||||
{
|
||||
mtx_.unlock();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
|
@ -11,6 +11,7 @@
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <system_error>
|
||||
|
||||
//
|
||||
@ -24,6 +25,8 @@ namespace system
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<unsigned Id> struct id_wrapper {};
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE std_category: public std::error_category
|
||||
{
|
||||
private:
|
||||
@ -39,20 +42,22 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
explicit std_category( boost::system::error_category const * pc, unsigned id ): pc_( pc )
|
||||
template<unsigned Id>
|
||||
explicit std_category( boost::system::error_category const * pc, id_wrapper<Id> ): pc_( pc )
|
||||
{
|
||||
if( id != 0 )
|
||||
{
|
||||
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
|
||||
|
||||
// Poking into the protected _Addr member of std::error_category
|
||||
// is not a particularly good programming practice, but what can
|
||||
// you do
|
||||
// We used to assign to the protected _Addr member of std::error_category
|
||||
// here when Id != 0, but this should never happen now because this code
|
||||
// path is no longer used
|
||||
|
||||
_Addr = id;
|
||||
#if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
|
||||
|
||||
static_assert( Id == 0, "This constructor should only be called with Id == 0 under MS STL 14.0+" );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
|
||||
|
@ -59,6 +59,7 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
case ERROR_ACCESS_DENIED_: return permission_denied;
|
||||
case ERROR_ALREADY_EXISTS_: return file_exists;
|
||||
case ERROR_BAD_NETPATH_: return no_such_file_or_directory;
|
||||
case ERROR_BAD_NET_NAME_: return no_such_file_or_directory;
|
||||
case ERROR_BAD_UNIT_: return no_such_device;
|
||||
case ERROR_BROKEN_PIPE_: return broken_pipe;
|
||||
case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
|
||||
@ -75,6 +76,7 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
case ERROR_DIR_NOT_EMPTY_: return directory_not_empty;
|
||||
case ERROR_DIRECTORY_: return invalid_argument; // WinError.h: "The directory name is invalid"
|
||||
case ERROR_DISK_FULL_: return no_space_on_device;
|
||||
case ERROR_FILENAME_EXCED_RANGE_: return filename_too_long;
|
||||
case ERROR_FILE_EXISTS_: return file_exists;
|
||||
case ERROR_FILE_NOT_FOUND_: return no_such_file_or_directory;
|
||||
case ERROR_HANDLE_DISK_FULL_: return no_space_on_device;
|
||||
@ -100,12 +102,16 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
case ERROR_REPARSE_TAG_INVALID_: return invalid_argument;
|
||||
case ERROR_RETRY_: return resource_unavailable_try_again;
|
||||
case ERROR_SEEK_: return io_error;
|
||||
case ERROR_SEM_TIMEOUT_: return timed_out;
|
||||
case ERROR_SHARING_VIOLATION_: return permission_denied;
|
||||
case ERROR_NOT_SUPPORTED_: return not_supported; // WinError.h: "The request is not supported."
|
||||
case ERROR_TIMEOUT_: return timed_out;
|
||||
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
|
||||
case ERROR_WRITE_FAULT_: return io_error;
|
||||
case ERROR_WRITE_PROTECT_: return permission_denied;
|
||||
|
||||
case 258: return timed_out; // WAIT_TIMEOUT
|
||||
|
||||
case WSAEACCES_: return permission_denied;
|
||||
case WSAEADDRINUSE_: return address_in_use;
|
||||
case WSAEADDRNOTAVAIL_: return address_not_available;
|
||||
|
@ -95,6 +95,14 @@ private:
|
||||
|
||||
variant2::variant<T, E> v_;
|
||||
|
||||
public:
|
||||
|
||||
using value_type = T;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
@ -135,7 +143,8 @@ public:
|
||||
template<class... A, class En = typename std::enable_if<
|
||||
std::is_constructible<T, A...>::value &&
|
||||
!(detail::is_errc_t<A...>::value && std::is_arithmetic<T>::value) &&
|
||||
!std::is_constructible<E, A...>::value
|
||||
!std::is_constructible<E, A...>::value &&
|
||||
sizeof...(A) >= 1
|
||||
>::type>
|
||||
explicit constexpr result( A&&... a )
|
||||
noexcept( std::is_nothrow_constructible<T, A...>::value )
|
||||
@ -146,7 +155,8 @@ public:
|
||||
// explicit, error
|
||||
template<class... A, class En2 = void, class En = typename std::enable_if<
|
||||
!std::is_constructible<T, A...>::value &&
|
||||
std::is_constructible<E, A...>::value
|
||||
std::is_constructible<E, A...>::value &&
|
||||
sizeof...(A) >= 1
|
||||
>::type>
|
||||
explicit constexpr result( A&&... a )
|
||||
noexcept( std::is_nothrow_constructible<E, A...>::value )
|
||||
@ -220,7 +230,7 @@ public:
|
||||
|
||||
constexpr bool has_error() const noexcept
|
||||
{
|
||||
return v_.index() != 0;
|
||||
return v_.index() == 1;
|
||||
}
|
||||
|
||||
constexpr explicit operator bool() const noexcept
|
||||
@ -391,6 +401,14 @@ public:
|
||||
return has_error()? variant2::unsafe_get<1>( v_ ): E();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
template<class... A>
|
||||
BOOST_CXX14_CONSTEXPR T& emplace( A&&... a )
|
||||
{
|
||||
return v_.template emplace<0>( std::forward<A>(a)... );
|
||||
}
|
||||
|
||||
// swap
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void swap( result& r )
|
||||
@ -442,6 +460,14 @@ private:
|
||||
|
||||
variant2::variant<variant2::monostate, E> v_;
|
||||
|
||||
public:
|
||||
|
||||
using value_type = void;
|
||||
using error_type = E;
|
||||
|
||||
static constexpr in_place_value_t in_place_value{};
|
||||
static constexpr in_place_error_t in_place_error{};
|
||||
|
||||
public:
|
||||
|
||||
// constructors
|
||||
@ -509,7 +535,7 @@ public:
|
||||
|
||||
constexpr bool has_error() const noexcept
|
||||
{
|
||||
return v_.index() != 0;
|
||||
return v_.index() == 1;
|
||||
}
|
||||
|
||||
constexpr explicit operator bool() const noexcept
|
||||
@ -555,6 +581,13 @@ public:
|
||||
return has_error()? variant2::unsafe_get<1>( v_ ): E();
|
||||
}
|
||||
|
||||
// emplace
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void emplace()
|
||||
{
|
||||
v_.template emplace<0>();
|
||||
}
|
||||
|
||||
// swap
|
||||
|
||||
BOOST_CXX14_CONSTEXPR void swap( result& r )
|
||||
|
@ -15,6 +15,7 @@ macro(system_run s1)
|
||||
boost_test(SOURCES ${s1} ${ARGN})
|
||||
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_NO_ANSI_APIS NAME ${n1}_no_ansi)
|
||||
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_SYSTEM_USE_UTF8 NAME ${n1}_utf8)
|
||||
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_SYSTEM_DISABLE_THREADS NAME ${n1}_nthr)
|
||||
|
||||
endmacro()
|
||||
|
||||
@ -124,6 +125,15 @@ boost_test(TYPE run SOURCES std_interop_test14.cpp)
|
||||
boost_test(TYPE run SOURCES ec_location_test3.cpp)
|
||||
boost_test(TYPE run SOURCES ec_location_test4.cpp)
|
||||
|
||||
boost_test(TYPE compile SOURCES constexpr_test2.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES error_code_test3.cpp)
|
||||
boost_test(TYPE run SOURCES std_interop_test15.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES win32_generic_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES ec_hash_value_test.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
@ -143,3 +153,6 @@ boost_test(TYPE run SOURCES result_range_for.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct2.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct2.cpp)
|
||||
boost_test(TYPE run SOURCES result_convert_construct.cpp)
|
||||
boost_test(TYPE run SOURCES result_typedefs.cpp)
|
||||
boost_test(TYPE run SOURCES result_value_construct3.cpp)
|
||||
boost_test(TYPE run SOURCES result_error_construct3.cpp)
|
||||
|
@ -33,6 +33,7 @@ rule system-run ( sources + )
|
||||
result += [ run $(sources) : : : <library>/boost/system//boost_system <link>shared : $(sources[1]:B)_shared ] ;
|
||||
result += [ run $(sources) : : : <define>BOOST_NO_ANSI_APIS : $(sources[1]:B)_no_ansi ] ;
|
||||
result += [ run $(sources) : : : <define>BOOST_SYSTEM_USE_UTF8 : $(sources[1]:B)_utf8 ] ;
|
||||
result += [ run $(sources) : : : <define>BOOST_SYSTEM_DISABLE_THREADS : $(sources[1]:B)_nthr ] ;
|
||||
|
||||
return $(result) ;
|
||||
}
|
||||
@ -152,6 +153,15 @@ run std_interop_test14.cpp ;
|
||||
run ec_location_test3.cpp ;
|
||||
run ec_location_test4.cpp ;
|
||||
|
||||
compile constexpr_test2.cpp ;
|
||||
|
||||
run error_code_test3.cpp ;
|
||||
run std_interop_test15.cpp ;
|
||||
|
||||
run win32_generic_test.cpp ;
|
||||
|
||||
run ec_hash_value_test.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
@ -174,3 +184,7 @@ run result_value_construct2.cpp : : : $(CPP11) ;
|
||||
run result_error_construct2.cpp : : : $(CPP11) ;
|
||||
run result_errc_construct.cpp : : : $(CPP11) ;
|
||||
run result_convert_construct.cpp : : : $(CPP11) ;
|
||||
run result_typedefs.cpp : : : $(CPP11) ;
|
||||
run result_value_construct3.cpp : : : $(CPP11) ;
|
||||
run result_error_construct3.cpp : : : $(CPP11) ;
|
||||
run result_emplace.cpp : : : $(CPP11) ;
|
||||
|
35
test/constexpr_test2.cpp
Normal file
35
test/constexpr_test2.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright 2022 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/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40700 && BOOST_GCC < 40800
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test, BOOST_GCC is 407xx")
|
||||
|
||||
#else
|
||||
|
||||
struct X
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
};
|
||||
|
||||
X const& f()
|
||||
{
|
||||
#if defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 30900
|
||||
|
||||
BOOST_STATIC_CONSTEXPR X x = {};
|
||||
return x;
|
||||
|
||||
#else
|
||||
|
||||
BOOST_STATIC_CONSTEXPR X x;
|
||||
return x;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
132
test/ec_hash_value_test.cpp
Normal file
132
test/ec_hash_value_test.cpp
Normal file
@ -0,0 +1,132 @@
|
||||
// Copyright 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cerrno>
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
#include <system_error>
|
||||
#endif
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
// normal against normal (equal, system)
|
||||
{
|
||||
sys::error_code e2( 0, sys::system_category() );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (equal, generic)
|
||||
{
|
||||
sys::error_code e2( EINVAL, sys::generic_category() );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, value, generic)
|
||||
{
|
||||
sys::error_code e2( 0, sys::generic_category() );
|
||||
sys::error_code e3( EINVAL, sys::generic_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, value, system)
|
||||
{
|
||||
sys::error_code e2( 1, sys::system_category() );
|
||||
sys::error_code e3( 2, sys::system_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, category)
|
||||
{
|
||||
sys::error_code e2( 0, sys::system_category() );
|
||||
sys::error_code e3( 0, sys::generic_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against normal
|
||||
{
|
||||
sys::error_code e2;
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
// std:: wrapping against normal
|
||||
{
|
||||
std::error_code e1( EINVAL, std::generic_category() );
|
||||
|
||||
sys::error_code e2( e1 );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against wrapping std:: empty
|
||||
{
|
||||
std::error_code e1;
|
||||
|
||||
sys::error_code e2( e1 );
|
||||
sys::error_code e3;
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against roundtrip via std
|
||||
{
|
||||
sys::error_code e2;
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal/generic against roundtrip via std
|
||||
{
|
||||
sys::error_code e2( EINVAL, boost::system::generic_category() );
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal/system against roundtrip via std
|
||||
{
|
||||
sys::error_code e2( 0, boost::system::system_category() );
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
69
test/error_code_test3.cpp
Normal file
69
test/error_code_test3.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
// Copyright 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/error_condition.hpp>
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
enomem_c = ENOMEM
|
||||
};
|
||||
|
||||
enum my_errn
|
||||
{
|
||||
enomem_n = ENOMEM
|
||||
};
|
||||
|
||||
namespace boost {
|
||||
namespace system {
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<> struct is_error_condition_enum<my_errn>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
sys::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return sys::error_code( e, sys::generic_category() );
|
||||
}
|
||||
|
||||
sys::error_condition make_error_condition( my_errn e )
|
||||
{
|
||||
return sys::error_condition( e, sys::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
sys::error_code ec = make_error_code( sys::errc::not_enough_memory );
|
||||
sys::error_condition en( sys::errc::not_enough_memory );
|
||||
|
||||
BOOST_TEST_EQ( ec, en );
|
||||
BOOST_TEST_EQ( en, ec );
|
||||
|
||||
BOOST_TEST_EQ( ec, enomem_c );
|
||||
BOOST_TEST_EQ( enomem_c, ec );
|
||||
|
||||
BOOST_TEST_EQ( ec, enomem_n );
|
||||
BOOST_TEST_EQ( enomem_n, ec );
|
||||
|
||||
BOOST_TEST_EQ( en, enomem_c );
|
||||
BOOST_TEST_EQ( enomem_c, en );
|
||||
|
||||
BOOST_TEST_EQ( en, enomem_n );
|
||||
BOOST_TEST_EQ( enomem_n, en );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -12,6 +12,11 @@ struct X
|
||||
{
|
||||
};
|
||||
|
||||
struct Y
|
||||
{
|
||||
Y( int );
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@ -37,5 +42,17 @@ int main()
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<int, int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<X>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<X, int>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<void>>));
|
||||
BOOST_TEST_TRAIT_TRUE((std::is_default_constructible<result<void, int>>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_default_constructible<result<Y, int>>));
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
176
test/result_emplace.cpp
Normal file
176
test/result_emplace.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
// 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>
|
||||
#include <cerrno>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( int v1, int v2 ): v_( v1+v2 ) { ++instances; }
|
||||
X( int v1, int v2, int v3 ): v_( v1+v2+v3 ) { ++instances; }
|
||||
|
||||
X( X const& ) = delete;
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
struct Y
|
||||
{
|
||||
static int instances;
|
||||
|
||||
Y() noexcept { ++instances; }
|
||||
|
||||
Y( Y const& ) noexcept { ++instances; }
|
||||
|
||||
Y& operator=( Y const& ) = default;
|
||||
|
||||
~Y() { --instances; }
|
||||
};
|
||||
|
||||
int Y::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
result<int> r;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
|
||||
r.emplace( 1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
}
|
||||
|
||||
{
|
||||
result<int> r( ENOENT, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
|
||||
r.emplace( 1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value(), 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<X> r( 0 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value().v_, 0 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
|
||||
r.emplace( 1 );
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
|
||||
r.emplace( 1, 2 );
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value().v_, 1+2 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
|
||||
r.emplace( 1, 2, 3 );
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value().v_, 1+2+3 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
result<X> r( ENOENT, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
r.emplace( 1, 2 );
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r.value().v_, 1+2 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
{
|
||||
result<int, Y> r( Y{} );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST_EQ( Y::instances, 1 );
|
||||
|
||||
r.emplace( 1 );
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
{
|
||||
result<X, Y> r( in_place_error );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
BOOST_TEST_EQ( Y::instances, 1 );
|
||||
|
||||
r.emplace( 1, 2, 3 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( r->v_, 1+2+3 );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
{
|
||||
result<void> r;
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
|
||||
r.emplace();
|
||||
BOOST_TEST( r.has_value() );
|
||||
}
|
||||
|
||||
{
|
||||
result<void> r( ENOENT, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
|
||||
r.emplace();
|
||||
BOOST_TEST( r.has_value() );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
|
||||
{
|
||||
result<void, Y> r( in_place_error );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST_EQ( Y::instances, 1 );
|
||||
|
||||
r.emplace();
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST_EQ( Y::instances, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
161
test/result_error_construct3.cpp
Normal file
161
test/result_error_construct3.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
// 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>
|
||||
#include <string>
|
||||
#include <cerrno>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
X(): v_() { ++instances; }
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( int v1, int v2 ): v_( v1+v2 ) { ++instances; }
|
||||
X( int v1, int v2, int v3 ): v_( v1+v2+v3 ) { ++instances; }
|
||||
|
||||
X( X const& r ): v_( r.v_ ) { ++instances; }
|
||||
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
using R = result<int>;
|
||||
R r( R::in_place_error, ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
using R = result<int>;
|
||||
R r( R::in_place_error, EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
using R = result<error_code>;
|
||||
R r( R::in_place_error, ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
using R = result<error_code>;
|
||||
R r( R::in_place_error, EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<std::string, X>;
|
||||
R r( R::in_place_error, 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<int, X>;
|
||||
R r( R::in_place_error, 1, 2 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1+2 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<int, X>;
|
||||
R r( R::in_place_error, 1, 2, 3 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1+2+3 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<X, X>;
|
||||
R r( R::in_place_error, 1 );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
auto ec = make_error_code( errc::invalid_argument );
|
||||
|
||||
using R = result<void>;
|
||||
R r( R::in_place_error, ec );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), ec );
|
||||
}
|
||||
|
||||
{
|
||||
using R = result<void>;
|
||||
R r( R::in_place_error, EINVAL, generic_category() );
|
||||
|
||||
BOOST_TEST( !r.has_value() );
|
||||
BOOST_TEST( r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.error(), error_code( EINVAL, generic_category() ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
22
test/result_typedefs.cpp
Normal file
22
test/result_typedefs.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 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_trait.hpp>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
struct X {};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_SAME( result<int>::value_type, int );
|
||||
BOOST_TEST_TRAIT_SAME( result<X>::value_type, X );
|
||||
BOOST_TEST_TRAIT_SAME( result<void>::value_type, void );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( result<int>::error_type, error_code );
|
||||
BOOST_TEST_TRAIT_SAME( result<int, X>::error_type, X );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <system_error>
|
||||
|
||||
using namespace boost::system;
|
||||
@ -223,7 +224,10 @@ int main()
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
#if defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 30600
|
||||
#else
|
||||
BOOST_TEST_THROWS( r.value(), E2 );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<int*>(0) );
|
||||
}
|
||||
@ -471,7 +475,10 @@ int main()
|
||||
BOOST_TEST_NOT( r );
|
||||
BOOST_TEST( !r );
|
||||
|
||||
#if defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 30600
|
||||
#else
|
||||
BOOST_TEST_THROWS( r.value(), E2 );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( r.operator->(), static_cast<void*>(0) );
|
||||
}
|
||||
|
118
test/result_value_construct3.cpp
Normal file
118
test/result_value_construct3.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
// 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
|
||||
{
|
||||
static int instances;
|
||||
|
||||
int v_;
|
||||
|
||||
explicit X( int v ): v_( v ) { ++instances; }
|
||||
|
||||
X( int v1, int v2 ): v_( v1+v2 ) { ++instances; }
|
||||
X( int v1, int v2, int v3 ): v_( v1+v2+v3 ) { ++instances; }
|
||||
|
||||
X( X const& ) = delete;
|
||||
X& operator=( X const& ) = delete;
|
||||
|
||||
~X() { --instances; }
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
using R = result<int>;
|
||||
R r( R::in_place_value, 0 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value(), 0 );
|
||||
}
|
||||
|
||||
{
|
||||
using R = result<int, int>;
|
||||
R r( R::in_place_value, 1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( *r, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<X>;
|
||||
R r( R::in_place_value, 1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<X>;
|
||||
R r( R::in_place_value, 1, 2 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1+2 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<X>;
|
||||
R r( R::in_place_value, 1, 2, 3 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r.value().v_, 1+2+3 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<X, X>;
|
||||
R r( R::in_place_value, 1 );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
|
||||
BOOST_TEST_EQ( r->v_, 1 );
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
|
||||
{
|
||||
using R = result<void>;
|
||||
R r( R::in_place_value );
|
||||
|
||||
BOOST_TEST( r.has_value() );
|
||||
BOOST_TEST( !r.has_error() );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
94
test/std_interop_test15.cpp
Normal file
94
test/std_interop_test15.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
// Copyright 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/error_condition.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY is defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
enomem_c = ENOMEM
|
||||
};
|
||||
|
||||
enum my_errn
|
||||
{
|
||||
enomem_n = ENOMEM
|
||||
};
|
||||
|
||||
namespace std {
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
template<> struct is_error_condition_enum<my_errn>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
std::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return std::error_code( e, std::generic_category() );
|
||||
}
|
||||
|
||||
std::error_condition make_error_condition( my_errn e )
|
||||
{
|
||||
return std::error_condition( e, std::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
sys::error_code ec = make_error_code( sys::errc::not_enough_memory );
|
||||
sys::error_condition en( sys::errc::not_enough_memory );
|
||||
|
||||
BOOST_TEST_EQ( ec, en );
|
||||
BOOST_TEST_EQ( en, ec );
|
||||
|
||||
BOOST_TEST_EQ( ec, enomem_c );
|
||||
BOOST_TEST_EQ( enomem_c, ec );
|
||||
|
||||
BOOST_TEST_EQ( ec, enomem_n );
|
||||
BOOST_TEST_EQ( enomem_n, ec );
|
||||
|
||||
BOOST_TEST_EQ( en, enomem_c );
|
||||
BOOST_TEST_EQ( enomem_c, en );
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1800)
|
||||
|
||||
// msvc-12.0 has op== as a member of std::error_condition
|
||||
|
||||
#else
|
||||
|
||||
BOOST_TEST_EQ( en, enomem_n );
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( enomem_n, en );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
52
test/win32_generic_test.cpp
Normal file
52
test/win32_generic_test.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2022 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_SYSTEM_HAS_SYSTEM_ERROR is not defined" )
|
||||
int main() {}
|
||||
|
||||
#elif !defined(BOOST_MSSTL_VERSION) || BOOST_MSSTL_VERSION < 140
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_MSSTL_VERSION is not defined or is less than 140" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
int n = 0;
|
||||
|
||||
for( int i = 0; i < 65000; ++i )
|
||||
{
|
||||
sys::error_code ec1( i, sys::system_category() );
|
||||
sys::error_condition en1 = ec1.default_error_condition();
|
||||
|
||||
std::error_code ec2( i, std::system_category() );
|
||||
std::error_condition en2 = ec2.default_error_condition();
|
||||
|
||||
if( en1 != en2 )
|
||||
{
|
||||
std::cout << i << ": " << en1 << " (" << en1.message() << ") != cond:" << en2.category().name() << ":" << en2.value() << " (" << en2.message() << ")\n";
|
||||
|
||||
if( en2.category() == std::generic_category() && i != 123 ) // msvc-14.0, msvc-14.1 disagree with us on ERROR_INVALID_NAME
|
||||
{
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n < 256 ? n: 255;
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user