Compare commits

...

98 Commits

Author SHA1 Message Date
39bd8ba98f Use address-model=32 for msvc-9.0, 10.0, 11.0 2020-10-06 13:29:14 +03:00
f1c0a52426 Fix typo 2020-10-06 04:44:07 +03:00
8962c9101a Update documentation 2020-10-06 04:26:02 +03:00
329e72fb92 Mark error_condition::failed, error_condition::message as deprecated; revert op bool 2020-10-06 04:03:13 +03:00
6758690d2f Add BOOST_SYSTEM_DEPRECATED; mark deprecated categories 2020-10-06 03:42:00 +03:00
8f32183b63 Mark platform-specific error headers as deprecated; split tests 2020-10-06 03:21:38 +03:00
99db03ee96 Remove tab 2020-09-04 17:02:14 +03:00
2e1ae5bc7a Remove unnecessary includes 2020-08-28 15:20:13 +03:00
7236be0c58 Add errc_test2 2020-08-28 02:00:20 +03:00
776834b723 Rename std_interoperability.hpp to to_std_category.hpp, make it self-contained 2020-08-28 01:03:15 +03:00
7d6da0ad91 Add tests for failed() 2020-08-27 17:49:20 +03:00
999cf08bf5 Add system_category_test3 2020-08-27 17:47:06 +03:00
96418c1531 Add generic_category_test3 2020-08-27 17:41:33 +03:00
717867cf4e Remove unnecessary includes 2020-08-27 17:40:27 +03:00
7e2a02b16d Rename system_category_posix.hpp to is_generic_value.hpp 2020-08-27 17:31:52 +03:00
b7e3be2798 Add system_category.hpp 2020-08-27 17:22:24 +03:00
e919caa2b4 Add generic_category.hpp 2020-08-27 16:35:32 +03:00
b951517625 Move system_category implementation to system_category_impl.hpp 2020-08-27 16:25:34 +03:00
ff18f28684 Move make_ functions for errc to errc.hpp 2020-08-27 16:15:10 +03:00
96321beb88 Add error_condition.hpp 2020-08-27 15:45:07 +03:00
313982fa52 Move interoperability support to error_category_impl.hpp 2020-08-27 15:14:17 +03:00
cc2b081a9e Add boost/system/error_category.hpp 2020-08-27 03:38:30 +03:00
a93572ab16 Extract error_category implementation into its own header 2020-08-27 03:23:00 +03:00
cc49bc4457 Extract throws into its own header 2020-08-27 03:06:14 +03:00
6bc7edbfa8 Rename generic_category_impl.hpp to generic_category_message.hpp 2020-08-27 02:59:30 +03:00
c345b86b0a Restore generic_category_impl.hpp; functions are needed by system_category 2020-08-27 02:56:18 +03:00
13bac420ab Move op!= for error_condition 2020-08-27 02:26:32 +03:00
abc94afdb2 Extract error_code into its own header 2020-08-27 02:23:50 +03:00
867ac5b446 Move generic_category(), system_category() to their respective headers; extract error_condition into its own header 2020-08-27 02:07:22 +03:00
d50db54c44 Move failed_impl into error_category.hpp 2020-08-27 01:36:44 +03:00
72ea1ef846 Extract enable_if into its own header 2020-08-27 01:21:56 +03:00
d581eb203e Extract system_error_category into its own header 2020-08-27 01:15:28 +03:00
3047581c75 Remove generic_category_impl.hpp 2020-08-27 01:06:54 +03:00
ddd679e6d7 Extract generic_error_category into its own header 2020-08-27 01:06:07 +03:00
4ec6c99148 Rename detail/generic_category.hpp 2020-08-27 00:51:03 +03:00
7b56fd9acf Extract error_category into its own header 2020-08-27 00:47:48 +03:00
b6a447cdde Extract errc into its own header 2020-08-27 00:31:45 +03:00
83019b5822 Extract is_error_code_enum, is_error_condition_enum into their own headers 2020-08-26 22:46:27 +03:00
8220aa5700 Include and test system_error.hpp in test/quick.cpp 2020-06-17 01:21:42 +03:00
f00c76a3fc Include and test system_error.hpp in warnings_test 2020-06-17 01:13:16 +03:00
73bf30ae04 Enable -Wsuggest-override in warnings_test; add BOOST_OVERRIDE appropriately 2020-06-17 01:06:40 +03:00
63ac7fb9bc Use <warnings>pedantic for warnings_test 2020-06-17 00:45:29 +03:00
feb545a919 Add gcc 10, clang 10, freebsd to Travis 2020-06-16 21:26:17 +03:00
00b30343b9 Asciidoctor 2 fixes 2020-06-16 21:01:38 +03:00
c91dbc8249 Update footer for Asciidoctor 2 2020-06-16 20:44:31 +03:00
00d85d8d37 Update revision history 2020-06-16 20:44:09 +03:00
5d3365717e Revert "Revert operator bool() to its pre-failed value() != 0 meaning"
This reverts commit 3164b387a5.
2020-06-16 20:24:23 +03:00
6942dc454b Fix unsupported use of BOOST_SYMBOL_VISIBLE on Sun C++ 2020-01-24 20:59:12 +02:00
7ba160e443 Rename id to id_ to avoid ObjC++ parsing issues. Fixes #52. 2020-01-18 22:15:44 +02:00
d9bfbfc4d4 Disable BUILD_TESTING on the install test 2020-01-18 15:26:21 +02:00
90cb8254df Install Core as well; add EXCLUDE_FROM_ALL to test libraries 2020-01-18 07:12:06 +02:00
4d1486dec9 Update CMakeLists.txt 2020-01-18 05:28:55 +02:00
97665bf539 Remove duplicate clang-3.6 2020-01-02 04:17:38 +02:00
6d82346e0b Fix .travis.yml mistakes 2020-01-02 02:57:24 +02:00
673dd13eaa Switch UBSAN from g++-8 to g++-9 2020-01-01 23:47:39 +02:00
ca525cd7b2 Update Travis to Xenial 2020-01-01 23:32:04 +02:00
9fb5bbd448 Remove 32 bit configuration from clang-win on Appveyor to avoid mspdbcore.dll error 2019-12-09 01:47:54 +02:00
31152834ac Add VS2019 to Appveyor; separate clang-win into its own job 2019-11-24 00:04:25 +02:00
455946faac Merge pull request #49 from Thomas-Barbier-1A/cpp7_redundant_redeclar_constexpr
Fix c++17 warning redundant redeclaration of 'constexpr' static data
2019-10-02 02:55:45 -07:00
08370c9158 Fix c++17 warning redundant redeclaration of 'constexpr' static data
member [-Werror=deprecated]
2019-10-01 18:49:31 +02:00
c556aba559 Remove redundant Travis job 2019-06-18 12:50:59 +03:00
ecc4ddd87c Add gcc9, clang8 to Travis 2019-06-18 12:46:04 +03:00
f67827eee3 Add dist: trusty to .travis.yml 2019-06-18 01:08:17 +03:00
c08b8a94ea Fix sign extension (warning 4826.) Closes #48. 2019-05-24 18:55:27 +03:00
835e5de228 Add clang-win to Appveyor 2019-05-14 04:16:53 +03:00
dc2ad73e30 Merge pull request #47 from KABoissonneault/feature/issue_46
Added boost::winapi::ERROR_CONNECTION_ABORTED_ to handled error codes…
2019-05-13 18:14:54 -07:00
32a6c13533 Added boost::winapi::ERROR_CONNECTION_ABORTED_ to handled error codes in Win32's system_category, making it equivalent to errc::connection_aborted 2019-05-13 18:08:24 -04:00
bfbc5ec42f Remove BOOST_SYSTEM_REQUIRE_CONST_INIT; variables are constexpr, so no longer needed. Closes #45. 2019-05-12 04:15:35 +03:00
9deadda4b4 Merge branch 'feature/system-generic-visible' into feature/std-ec-mismatch 2019-04-25 20:54:01 +03:00
3b6315e4a1 Add BOOST_SYMBOL_VISIBLE to system_category(), generic_category() 2019-04-25 16:55:13 +03:00
1d845408dd Fix thread safety issue in std interop 2019-04-25 01:01:48 +03:00
e08e4253d0 Avoid allocation on interop for system/generic categories; fix DLL interoperability on msvc-14.x by poking into std::system_category::_Addr 2019-04-25 00:31:25 +03:00
afc51937be Mark to_std_category as BOOST_SYMBOL_VISIBLE 2019-04-24 23:18:19 +03:00
907c867cd1 Rename test/std_ec_mismatch to std_single_instance; test also static and shared libraries 2019-04-24 21:15:39 +03:00
9f225112f1 Add std_ec_mismatch_test 2019-04-24 18:19:21 +03:00
48b8a6c41c Switch Appveyor to 2015 image 2019-04-14 18:06:05 +03:00
9b8cb7f1f6 Fix wrong null character stripping for FormatMessage (Nikita Kniazev) 2019-03-24 01:59:23 +02:00
90b2356015 system_error_test: Increase tested messages range (Nikita Kniazev) 2019-03-24 00:24:05 +02:00
1c36a72b79 Merge pull request #40 from Kojoley/system_error_test-mingw-non-en
system_error_test: Enable locale query on MinGW-w64
2019-03-17 11:28:45 +02:00
7947d0ed0d system_error_test: Reenable locale query on MinGW and Cygwin 2019-03-17 01:53:37 +03:00
72d3e96c73 Disable English-dependent test; fixes #39. 2019-03-16 19:51:21 +02:00
ca882f286c Skip system_category_test_utf8; comparing against FormatMessageA isn't going to work. Fixes #38. 2019-03-16 19:44:43 +02:00
df78f08bd2 Merge pull request #37 from Kojoley/patch-1
system_category_test: Increase buffer size
2019-03-16 19:02:47 +02:00
f878f41fe7 system_category_test: Increase buffer size
The message for 5810 error does not fit into buffer on non-English locales.
2019-03-16 01:55:18 +03:00
0134441a6e Add warnings_test.cpp; disable -Wnon-virtual-dtor on g++ < 4.6 2019-03-04 19:23:32 +02:00
c705bab504 #pragma GCC diagnostic push/pop requires gcc 4.6 2019-03-04 17:38:52 +02:00
af1dc84160 Disable -Wnon-virtual-dtor 2019-03-04 16:35:35 +02:00
2d37749d00 Enable -Wnon-virtual-dtor in warnings_test 2019-03-04 15:40:03 +02:00
3164b387a5 Revert operator bool() to its pre-failed value() != 0 meaning 2019-02-27 21:10:57 +02:00
9753cf7668 Update test/Jamfile 2019-02-27 06:23:16 +02:00
ef7c34fc30 Remove use of _alloca 2019-02-26 17:22:58 +02:00
f726c068c3 Add UTF-8 tests 2019-02-26 16:42:47 +02:00
2929d2dea2 Fix .travis.yml 2019-01-06 04:38:22 +02:00
2c01c5d5c8 Add test/cmake_subdir_test 2019-01-05 19:55:38 +02:00
5ab9a5117d Update CMakeLists.txt 2019-01-04 19:38:01 +02:00
ee916382df [CMake] Generate cmake target that other libraries can use
... to express their dependency on this library and retrieve any
configuration information such as the include directory, binary
to link to (if any), transitive dependencies, necessary compiler
options or the required c++ standards level.
2018-12-23 22:47:51 +01:00
fc1f2f4845 Remove essentials from yml files 2018-12-22 05:14:53 +02:00
65daf972d3 Update .yml files 2018-12-18 21:56:44 +02:00
64 changed files with 3379 additions and 1933 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2016, 2017, 2018 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -6,7 +6,7 @@ language: cpp
sudo: false
python: "2.7"
dist: xenial
branches:
only:
@ -109,7 +109,7 @@ matrix:
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
@ -118,12 +118,33 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
@ -132,6 +153,7 @@ matrix:
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -140,6 +162,7 @@ matrix:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -148,16 +171,15 @@ matrix:
- clang-3.4
- os: linux
dist: trusty
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
@ -168,19 +190,6 @@ matrix:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
- os: linux
compiler: clang++-3.7
@ -191,19 +200,6 @@ matrix:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
- os: linux
compiler: clang++-3.8
@ -214,19 +210,6 @@ matrix:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
- os: linux
compiler: clang++-3.9
@ -237,19 +220,6 @@ matrix:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.9
- os: linux
compiler: clang++-4.0
@ -260,19 +230,6 @@ matrix:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-4.0
- os: linux
compiler: clang++-5.0
@ -283,19 +240,6 @@ matrix:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
- libstdc++-4.9-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-5.0
- os: linux
compiler: clang++-6.0
@ -306,33 +250,69 @@ matrix:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-6.0
- libstdc++-4.9-dev
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-6.0
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-8
- os: linux
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: xenial
compiler: clang++-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: xenial
compiler: clang++-10
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
@ -341,6 +321,7 @@ matrix:
- libc++-dev
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
@ -352,13 +333,60 @@ matrix:
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: freebsd
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
- os: linux
env: CMAKE=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- ctest --output-on-failure -R boost_system
- os: linux
env: CMAKE=1 BUILD_SHARED_LIBS=ON
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- ctest --output-on-failure -R boost_system
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH https://github.com/boostorg/predef.git ../predef
- git clone -b $BOOST_BRANCH https://github.com/boostorg/winapi.git ../winapi
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES="system;core" -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/system
- python tools/boostdep/depinst/depinst.py system

24
CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
# Copyright 2018-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_system INTERFACE)
add_library(Boost::system ALIAS boost_system)
target_include_directories(boost_system INTERFACE include)
target_link_libraries(boost_system
INTERFACE
Boost::config
Boost::winapi
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@ -1,4 +1,4 @@
# Copyright 2016-2018 Peter Dimov
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -14,28 +14,37 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
CXXSTD: 14,17
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
@ -46,10 +55,8 @@ install:
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\system
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\system\
- python tools/boostdep/depinst/depinst.py system
- cmd /c bootstrap
- b2 -d0 headers

View File

@ -1,5 +1,6 @@
<style>
*:not(pre)>code { background: none; color: #600000; }
:not(pre):not([class^=L])>code { background: none; color: #600000; }
</style>

View File

@ -8,9 +8,30 @@ http://www.boost.org/LICENSE_1_0.txt
////
[#changes]
# Release History
# Revision History
:idprefix:
## Changes in Boost 1.75
* The platform-specific headers `windows_error.hpp`, `linux_error.hpp`,
and `cygwin_error.hpp` emit deprecation messages and are slated for
removal.
* The old names for `generic_category()` and `system_category()` emit
deprecation messages and are slated for removal.
* `error_condition::failed` is deprecated and is slated for removal.
`operator bool()` for `error_condition` has been reverted to its old
meaning of `value() != 0`. This is done for compatibility with
`std::error_condition` as the next release is expected to improve
interoperability with `<system_error>` even further. _Note that this
does not affect_ `error_code::failed`, which is still alive and well.
* The overload of `error_condition::message` that takes a buffer is
deprecated and is slated for removal, for the same reasons. _Note that
this does not affect_ `error_code::message`.
## Changes in Boost 1.74
* `operator bool()` now returns `failed()` instead of `value() != 0`.
## Changes in Boost 1.69
* Boost.System is now header-only. A stub library is still built for

View File

@ -568,7 +568,8 @@ constexpr void clear() noexcept;
[none]
* {blank}
+
Ensures: :: `val_ == 0`; `*cat_ == system_category()`.
Ensures: ::
`val_ == 0`; `*cat_ == system_category()`.
#### Observers
@ -634,7 +635,8 @@ operator std::error_code() const;
[none]
* {blank}
+
Returns: :: `std::error_code( val_, *cat_ )`.
Returns: ::
`std::error_code( val_, *cat_ )`.
### Class error_condition
@ -668,13 +670,16 @@ namespace boost {
constexpr const error_category & category() const noexcept;
std::string message() const;
char const * message( char * buffer, std::size_t len ) const noexcept;
constexpr bool failed() const noexcept;
constexpr explicit operator bool() const noexcept;
operator std::error_condition() const;
// deprecated members; do not use
char const * message( char * buffer, std::size_t len ) const noexcept;
constexpr bool failed() const noexcept;
private: // exposition only
int val_;
@ -711,7 +716,8 @@ template <class ErrorConditionEnum>
* {blank}
+
Ensures: :: `*this == make_error_condition( e )`.
Remarks: :: This constructor is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`.
Remarks: ::
This constructor is only enabled when `is_error_condition_enum<ErrorConditionEnum>::value` is `true`.
#### Modifiers
@ -739,7 +745,8 @@ constexpr void clear() noexcept;
[none]
* {blank}
+
Ensures: :: `val_ == 0`; `*cat_ == generic_category()`.
Ensures: ::
`val_ == 0`; `*cat_ == generic_category()`.
#### Observers
@ -767,6 +774,25 @@ std::string message() const;
+
Returns: :: `cat_\->message( val_ )`.
```
constexpr explicit operator bool() const noexcept;
```
[none]
* {blank}
+
Returns: :: `value() != 0`.
```
operator std::error_condition() const;
```
[none]
* {blank}
+
Returns: ::
`std::error_condition( val_, *cat_ )`.
#### Deprecated members
```
char const * message( char * buffer, std::size_t len ) const noexcept;
```
@ -775,6 +801,11 @@ char const * message( char * buffer, std::size_t len ) const noexcept;
+
Returns: :: `cat_\->message( val_, buffer, len )`.
WARNING: This member function is deprecated and will be removed. This is done
for compatibility with `std::error_condition` as the next release is
expected to improve interoperability with `<system_error>` even further.
_Note that this does not affect_ `error_code::message`.
```
constexpr bool failed() const noexcept;
```
@ -783,21 +814,10 @@ constexpr bool failed() const noexcept;
+
Returns: :: `cat_\->failed( val_ )`.
```
constexpr explicit operator bool() const noexcept;
```
[none]
* {blank}
+
Returns: :: `failed()`.
```
operator std::error_condition() const;
```
[none]
* {blank}
+
Returns: :: `std::error_condition( val_, *cat_ )`.
WARNING: This member function is deprecated and will be removed. This is done
for compatibility with `std::error_condition` as the next release is
expected to improve interoperability with `<system_error>` even further.
_Note that this does not affect_ `error_code::failed`.
### Nonmember functions
@ -882,7 +902,8 @@ std::size_t hash_value( const error_code & ec );
[none]
* {blank}
+
Returns: :: A hash value representing `ec`.
Returns: ::
A hash value representing `ec`.
## <boost/system/system_error.hpp>
@ -941,7 +962,8 @@ system_error( int ev, const error_category & ecat );
[none]
* {blank}
+
Ensures: :: `code() == error_code( ev, ecat )`.
Ensures: ::
`code() == error_code( ev, ecat )`.
#### Observers

View File

@ -7,325 +7,9 @@
// See library home page at http://www.boost.org/libs/system
#ifndef BOOST_SYSTEM_CERRNO_HPP
#define BOOST_SYSTEM_CERRNO_HPP
#ifndef BOOST_CERRNO_HPP_INCLUDED
#define BOOST_CERRNO_HPP_INCLUDED
#include <cerrno>
#include <boost/system/detail/cerrno.hpp>
// supply errno values likely to be missing, particularly on Windows
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT 9901
#endif
#ifndef EADDRINUSE
#define EADDRINUSE 9902
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL 9903
#endif
#ifndef EISCONN
#define EISCONN 9904
#endif
#ifndef EBADMSG
#define EBADMSG 9905
#endif
#ifndef ECONNABORTED
#define ECONNABORTED 9906
#endif
#ifndef EALREADY
#define EALREADY 9907
#endif
#ifndef ECONNREFUSED
#define ECONNREFUSED 9908
#endif
#ifndef ECONNRESET
#define ECONNRESET 9909
#endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ 9910
#endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH 9911
#endif
#ifndef EIDRM
#define EIDRM 9912
#endif
#ifndef EMSGSIZE
#define EMSGSIZE 9913
#endif
#ifndef ENETDOWN
#define ENETDOWN 9914
#endif
#ifndef ENETRESET
#define ENETRESET 9915
#endif
#ifndef ENETUNREACH
#define ENETUNREACH 9916
#endif
#ifndef ENOBUFS
#define ENOBUFS 9917
#endif
#ifndef ENOLINK
#define ENOLINK 9918
#endif
#ifndef ENODATA
#define ENODATA 9919
#endif
#ifndef ENOMSG
#define ENOMSG 9920
#endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 9921
#endif
#ifndef ENOSR
#define ENOSR 9922
#endif
#ifndef ENOTSOCK
#define ENOTSOCK 9923
#endif
#ifndef ENOSTR
#define ENOSTR 9924
#endif
#ifndef ENOTCONN
#define ENOTCONN 9925
#endif
#ifndef ENOTSUP
#define ENOTSUP 9926
#endif
#ifndef ECANCELED
#define ECANCELED 9927
#endif
#ifndef EINPROGRESS
#define EINPROGRESS 9928
#endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP 9929
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK 9930
#endif
#ifndef EOWNERDEAD
#define EOWNERDEAD 9931
#endif
#ifndef EPROTO
#define EPROTO 9932
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT 9933
#endif
#ifndef ENOTRECOVERABLE
#define ENOTRECOVERABLE 9934
#endif
#ifndef ETIME
#define ETIME 9935
#endif
#ifndef ETXTBSY
#define ETXTBSY 9936
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 9938
#endif
#ifndef ELOOP
#define ELOOP 9939
#endif
#ifndef EOVERFLOW
#define EOVERFLOW 9940
#endif
#ifndef EPROTOTYPE
#define EPROTOTYPE 9941
#endif
#ifndef ENOSYS
#define ENOSYS 9942
#endif
#ifndef EINVAL
#define EINVAL 9943
#endif
#ifndef ERANGE
#define ERANGE 9944
#endif
#ifndef EILSEQ
#define EILSEQ 9945
#endif
// Windows Mobile doesn't appear to define these:
#ifndef E2BIG
#define E2BIG 9946
#endif
#ifndef EDOM
#define EDOM 9947
#endif
#ifndef EFAULT
#define EFAULT 9948
#endif
#ifndef EBADF
#define EBADF 9949
#endif
#ifndef EPIPE
#define EPIPE 9950
#endif
#ifndef EXDEV
#define EXDEV 9951
#endif
#ifndef EBUSY
#define EBUSY 9952
#endif
#ifndef ENOTEMPTY
#define ENOTEMPTY 9953
#endif
#ifndef ENOEXEC
#define ENOEXEC 9954
#endif
#ifndef EEXIST
#define EEXIST 9955
#endif
#ifndef EFBIG
#define EFBIG 9956
#endif
#ifndef ENAMETOOLONG
#define ENAMETOOLONG 9957
#endif
#ifndef ENOTTY
#define ENOTTY 9958
#endif
#ifndef EINTR
#define EINTR 9959
#endif
#ifndef ESPIPE
#define ESPIPE 9960
#endif
#ifndef EIO
#define EIO 9961
#endif
#ifndef EISDIR
#define EISDIR 9962
#endif
#ifndef ECHILD
#define ECHILD 9963
#endif
#ifndef ENOLCK
#define ENOLCK 9964
#endif
#ifndef ENOSPC
#define ENOSPC 9965
#endif
#ifndef ENXIO
#define ENXIO 9966
#endif
#ifndef ENODEV
#define ENODEV 9967
#endif
#ifndef ENOENT
#define ENOENT 9968
#endif
#ifndef ESRCH
#define ESRCH 9969
#endif
#ifndef ENOTDIR
#define ENOTDIR 9970
#endif
#ifndef ENOMEM
#define ENOMEM 9971
#endif
#ifndef EPERM
#define EPERM 9972
#endif
#ifndef EACCES
#define EACCES 9973
#endif
#ifndef EROFS
#define EROFS 9974
#endif
#ifndef EDEADLK
#define EDEADLK 9975
#endif
#ifndef EAGAIN
#define EAGAIN 9976
#endif
#ifndef ENFILE
#define ENFILE 9977
#endif
#ifndef EMFILE
#define EMFILE 9978
#endif
#ifndef EMLINK
#define EMLINK 9979
#endif
#endif // include guard
#endif // #ifndef BOOST_CERRNO_HPP_INCLUDED

View File

@ -10,6 +10,13 @@
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
#include <boost/config/pragma_message.hpp>
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
" If you want it retained, please open an issue in github.com/boostorg/system.")
#endif
// This header is effectively empty for compiles on operating systems where
// it is not applicable.

View File

@ -0,0 +1,329 @@
// Copyright Beman Dawes 2005.
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See library home page at http://www.boost.org/libs/system
#ifndef BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED
#include <cerrno>
// supply errno values likely to be missing, particularly on Windows
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT 9901
#endif
#ifndef EADDRINUSE
#define EADDRINUSE 9902
#endif
#ifndef EADDRNOTAVAIL
#define EADDRNOTAVAIL 9903
#endif
#ifndef EISCONN
#define EISCONN 9904
#endif
#ifndef EBADMSG
#define EBADMSG 9905
#endif
#ifndef ECONNABORTED
#define ECONNABORTED 9906
#endif
#ifndef EALREADY
#define EALREADY 9907
#endif
#ifndef ECONNREFUSED
#define ECONNREFUSED 9908
#endif
#ifndef ECONNRESET
#define ECONNRESET 9909
#endif
#ifndef EDESTADDRREQ
#define EDESTADDRREQ 9910
#endif
#ifndef EHOSTUNREACH
#define EHOSTUNREACH 9911
#endif
#ifndef EIDRM
#define EIDRM 9912
#endif
#ifndef EMSGSIZE
#define EMSGSIZE 9913
#endif
#ifndef ENETDOWN
#define ENETDOWN 9914
#endif
#ifndef ENETRESET
#define ENETRESET 9915
#endif
#ifndef ENETUNREACH
#define ENETUNREACH 9916
#endif
#ifndef ENOBUFS
#define ENOBUFS 9917
#endif
#ifndef ENOLINK
#define ENOLINK 9918
#endif
#ifndef ENODATA
#define ENODATA 9919
#endif
#ifndef ENOMSG
#define ENOMSG 9920
#endif
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 9921
#endif
#ifndef ENOSR
#define ENOSR 9922
#endif
#ifndef ENOTSOCK
#define ENOTSOCK 9923
#endif
#ifndef ENOSTR
#define ENOSTR 9924
#endif
#ifndef ENOTCONN
#define ENOTCONN 9925
#endif
#ifndef ENOTSUP
#define ENOTSUP 9926
#endif
#ifndef ECANCELED
#define ECANCELED 9927
#endif
#ifndef EINPROGRESS
#define EINPROGRESS 9928
#endif
#ifndef EOPNOTSUPP
#define EOPNOTSUPP 9929
#endif
#ifndef EWOULDBLOCK
#define EWOULDBLOCK 9930
#endif
#ifndef EOWNERDEAD
#define EOWNERDEAD 9931
#endif
#ifndef EPROTO
#define EPROTO 9932
#endif
#ifndef EPROTONOSUPPORT
#define EPROTONOSUPPORT 9933
#endif
#ifndef ENOTRECOVERABLE
#define ENOTRECOVERABLE 9934
#endif
#ifndef ETIME
#define ETIME 9935
#endif
#ifndef ETXTBSY
#define ETXTBSY 9936
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 9938
#endif
#ifndef ELOOP
#define ELOOP 9939
#endif
#ifndef EOVERFLOW
#define EOVERFLOW 9940
#endif
#ifndef EPROTOTYPE
#define EPROTOTYPE 9941
#endif
#ifndef ENOSYS
#define ENOSYS 9942
#endif
#ifndef EINVAL
#define EINVAL 9943
#endif
#ifndef ERANGE
#define ERANGE 9944
#endif
#ifndef EILSEQ
#define EILSEQ 9945
#endif
// Windows Mobile doesn't appear to define these:
#ifndef E2BIG
#define E2BIG 9946
#endif
#ifndef EDOM
#define EDOM 9947
#endif
#ifndef EFAULT
#define EFAULT 9948
#endif
#ifndef EBADF
#define EBADF 9949
#endif
#ifndef EPIPE
#define EPIPE 9950
#endif
#ifndef EXDEV
#define EXDEV 9951
#endif
#ifndef EBUSY
#define EBUSY 9952
#endif
#ifndef ENOTEMPTY
#define ENOTEMPTY 9953
#endif
#ifndef ENOEXEC
#define ENOEXEC 9954
#endif
#ifndef EEXIST
#define EEXIST 9955
#endif
#ifndef EFBIG
#define EFBIG 9956
#endif
#ifndef ENAMETOOLONG
#define ENAMETOOLONG 9957
#endif
#ifndef ENOTTY
#define ENOTTY 9958
#endif
#ifndef EINTR
#define EINTR 9959
#endif
#ifndef ESPIPE
#define ESPIPE 9960
#endif
#ifndef EIO
#define EIO 9961
#endif
#ifndef EISDIR
#define EISDIR 9962
#endif
#ifndef ECHILD
#define ECHILD 9963
#endif
#ifndef ENOLCK
#define ENOLCK 9964
#endif
#ifndef ENOSPC
#define ENOSPC 9965
#endif
#ifndef ENXIO
#define ENXIO 9966
#endif
#ifndef ENODEV
#define ENODEV 9967
#endif
#ifndef ENOENT
#define ENOENT 9968
#endif
#ifndef ESRCH
#define ESRCH 9969
#endif
#ifndef ENOTDIR
#define ENOTDIR 9970
#endif
#ifndef ENOMEM
#define ENOMEM 9971
#endif
#ifndef EPERM
#define EPERM 9972
#endif
#ifndef EACCES
#define EACCES 9973
#endif
#ifndef EROFS
#define EROFS 9974
#endif
#ifndef EDEADLK
#define EDEADLK 9975
#endif
#ifndef EAGAIN
#define EAGAIN 9976
#endif
#ifndef ENFILE
#define ENFILE 9977
#endif
#ifndef EMFILE
#define EMFILE 9978
#endif
#ifndef EMLINK
#define EMLINK 9979
#endif
#endif // #ifndef BOOST_SYSTEM_DETAIL_CERRNO_HPP_INCLUDED

View File

@ -22,6 +22,11 @@
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
#if defined(BOOST_NO_CXX11_HDR_MUTEX)
// Required for thread-safe map manipulation
# undef BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
// BOOST_SYSTEM_NOEXCEPT
// Retained for backward compatibility
@ -43,15 +48,18 @@
# define BOOST_SYSTEM_CONSTEXPR
#endif
// BOOST_SYSTEM_REQUIRE_CONST_INIT
// BOOST_SYSTEM_DEPRECATED
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(clang::require_constant_initialization)
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
#endif
#if defined(__clang__)
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
#elif defined(__GNUC__)
# if __GNUC__ * 100 + __GNUC_MINOR__ >= 405
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
# else
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated))
# endif
#elif defined(_MSC_VER)
# define BOOST_SYSTEM_DEPRECATED(msg) __declspec(deprecated(msg))
#endif
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED

View File

@ -0,0 +1,32 @@
#ifndef BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
namespace boost
{
namespace system
{
namespace detail
{
template<bool C, class T = void> struct enable_if
{
typedef T type;
};
template<class T> struct enable_if<false, T>
{
};
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ENABLE_IF_HPP_INCLUDED

View File

@ -0,0 +1,126 @@
#ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 2018, 2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/is_error_condition_enum.hpp>
#include <boost/system/detail/cerrno.hpp>
namespace boost
{
namespace system
{
namespace errc
{
enum errc_t
{
success = 0,
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
address_not_available = EADDRNOTAVAIL,
already_connected = EISCONN,
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
bad_message = EBADMSG,
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
identifier_removed = EIDRM,
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
no_link = ENOLINK,
no_lock_available = ENOLCK,
no_message_available = ENODATA,
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
no_stream_resources = ENOSR,
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
not_a_stream = ENOSTR,
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
not_supported = ENOTSUP,
operation_canceled = ECANCELED,
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
owner_dead = EOWNERDEAD,
permission_denied = EACCES,
protocol_error = EPROTO,
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
state_not_recoverable = ENOTRECOVERABLE,
stream_timeout = ETIME,
text_file_busy = ETXTBSY,
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_symbolic_link_levels = ELOOP,
value_too_large = EOVERFLOW,
wrong_protocol_type = EPROTOTYPE
};
} // namespace errc
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
namespace posix = errc;
namespace posix_error = errc;
#endif
template<> struct is_error_condition_enum<errc::errc_t>
{
static const bool value = true;
};
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED

View File

@ -0,0 +1,189 @@
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <string>
#include <functional>
#include <cstddef>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
# include <system_error>
#endif
namespace boost
{
namespace system
{
class error_category;
class error_code;
class error_condition;
std::size_t hash_value( error_code const & ec );
namespace detail
{
BOOST_SYSTEM_CONSTEXPR bool failed_impl( int ev, error_category const & cat );
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
std::error_category const & to_std_category( error_category const & cat );
#endif
} // namespace detail
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class BOOST_SYMBOL_VISIBLE error_category
{
private:
friend std::size_t hash_value( error_code const & ec );
friend BOOST_SYSTEM_CONSTEXPR bool detail::failed_impl( int ev, error_category const & cat );
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
friend std::error_category const & detail::to_std_category( error_category const & cat );
#endif
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
public:
error_category( error_category const & ) = delete;
error_category& operator=( error_category const & ) = delete;
#else
private:
error_category( error_category const & );
error_category& operator=( error_category const & );
#endif
private:
boost::ulong_long_type id_;
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
~error_category() = default;
#else
// We'd like to make the destructor protected, to make code that deletes
// an error_category* not compile; unfortunately, doing the below makes
// the destructor user-provided and hence breaks use after main, as the
// categories may get destroyed before code that uses them
// ~error_category() {}
#endif
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
{
}
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
{
}
public:
virtual const char * name() const BOOST_NOEXCEPT = 0;
virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT;
virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
virtual std::string message( int ev ) const = 0;
virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
virtual bool failed( int ev ) const BOOST_NOEXCEPT
{
return ev != 0;
}
BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
{
return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
}
BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
{
return !( *this == rhs );
}
BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
{
if( id_ < rhs.id_ )
{
return true;
}
if( id_ > rhs.id_ )
{
return false;
}
if( rhs.id_ != 0 )
{
return false; // equal
}
return std::less<error_category const *>()( this, &rhs );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_category const & () const;
#endif
};
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic pop
#endif
namespace detail
{
static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D;
static const boost::ulong_long_type system_category_id = ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B;
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
{
if( cat.id_ == system_category_id || cat.id_ == generic_category_id )
{
return ev != 0;
}
else
{
return cat.failed( ev );
}
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,108 @@
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/config.hpp>
#include <string>
#include <cstring>
namespace boost
{
namespace system
{
// error_category default implementation
inline error_condition error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return error_condition( ev, *this );
}
inline bool error_category::equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT
{
return default_error_condition( code ) == condition;
}
inline bool error_category::equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT
{
return *this == code.category() && code.value() == condition;
}
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
try
#endif
{
std::string m = this->message( ev );
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic push
# if __has_warning("-Wdeprecated-declarations")
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
# endif
std::strncpy( buffer, m.c_str(), len - 1 );
buffer[ len-1 ] = 0;
# if defined( BOOST_MSVC )
# pragma warning( pop )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic pop
# endif
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
catch( ... )
{
return "Message text unavailable";
}
#endif
}
} // namespace system
} // namespace boost
// interoperability with std::error_code, std::error_condition
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <boost/system/detail/to_std_category.hpp>
inline boost::system::error_category::operator std::error_category const & () const
{
return boost::system::detail::to_std_category( *this );
}
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED

View File

@ -0,0 +1,215 @@
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/system_category.hpp>
#include <boost/system/detail/enable_if.hpp>
#include <boost/system/is_error_code_enum.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <ostream>
namespace boost
{
namespace system
{
// class error_code
// We want error_code to be a value type that can be copied without slicing
// and without requiring heap allocation, but we also want it to have
// polymorphic behavior based on the error category. This is achieved by
// abstract base class error_category supplying the polymorphic behavior,
// and error_code containing a pointer to an object of a type derived
// from error_category.
class error_code
{
private:
int val_;
bool failed_;
const error_category * cat_;
public:
// constructors:
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
val_( 0 ), failed_( false ), cat_( &system_category() )
{
}
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
{
}
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT
{
*this = make_error_code( e );
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
{
val_ = val;
failed_ = detail::failed_impl( val, cat );
cat_ = &cat;
}
template<typename ErrorCodeEnum>
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT
{
*this = make_error_code( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
{
val_ = 0;
failed_ = false;
cat_ = &system_category();
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
{
return val_;
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
{
return *cat_;
}
error_condition default_error_condition() const BOOST_NOEXCEPT
{
return cat_->default_error_condition( value() );
}
std::string message() const
{
return cat_->message( value() );
}
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return cat_->message( value(), buffer, len );
}
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
{
return failed_;
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
{
return failed_;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
{
return failed_? unspecified_bool_true: 0;
}
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
{
return !failed_;
}
#endif
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_code () const
{
return std::error_code( value(), category() );
}
#endif
};
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return !( lhs == rhs );
}
template<class Ch, class Tr>
inline std::basic_ostream<Ch, Tr>&
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
{
os << ec.category().name() << ':' << ec.value();
return os;
}
inline std::size_t hash_value( error_code const & ec )
{
error_category const & cat = ec.category();
boost::ulong_long_type id_ = cat.id_;
if( id_ == 0 )
{
id_ = reinterpret_cast<boost::uintptr_t>( &cat );
}
boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325;
boost::ulong_long_type const prime = ( boost::ulong_long_type( 0x00000100 ) << 32 ) + 0x000001B3;
// id
hv ^= id_;
hv *= prime;
// value
hv ^= static_cast<unsigned>( ec.value() );
hv *= prime;
return static_cast<std::size_t>( hv );
}
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED

View File

@ -0,0 +1,163 @@
#ifndef BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/generic_category.hpp>
#include <boost/system/detail/enable_if.hpp>
#include <boost/system/is_error_condition_enum.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace system
{
// class error_condition
// error_conditions are portable, error_codes are system or library specific
class error_condition
{
private:
int val_;
error_category const * cat_;
public:
// constructors:
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
val_( 0 ), cat_( &generic_category() )
{
}
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
val_( val ), cat_( &cat )
{
}
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type* = 0) BOOST_NOEXCEPT
{
*this = make_error_condition( e );
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
{
val_ = val;
cat_ = &cat;
}
template<typename ErrorConditionEnum>
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
{
*this = make_error_condition( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
{
val_ = 0;
cat_ = &generic_category();
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
{
return val_;
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
{
return *cat_;
}
std::string message() const
{
return cat_->message( value() );
}
BOOST_SYSTEM_DEPRECATED("this function is slated for removal") char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return cat_->message( value(), buffer, len );
}
BOOST_SYSTEM_DEPRECATED("this function is slated for removal") BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
{
return detail::failed_impl( val_, *cat_ );
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
{
return val_ != 0;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
{
return val_ != 0? unspecified_bool_true: 0;
}
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
{
return val_ == 0;
}
#endif
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_condition () const
{
return std::error_condition( value(), category() );
}
#endif
};
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return !( lhs == rhs );
}
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CONDITION_HPP_INCLUDED

View File

@ -1,13 +1,19 @@
// Implementation details of generic_error_category
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED
#include <cstring>
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/generic_category_message.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/config.hpp>
namespace boost
{
@ -18,84 +24,100 @@ namespace system
namespace detail
{
#if defined(__GLIBC__)
// generic_error_category
// glibc has two incompatible strerror_r definitions
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
inline char const * strerror_r_helper( char const * r, char const * ) BOOST_NOEXCEPT
class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
{
return r;
}
public:
inline char const * strerror_r_helper( int r, char const * buffer ) BOOST_NOEXCEPT
{
return r == 0? buffer: "Unknown error";
}
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
}
inline std::string generic_error_category_message( int ev )
{
char buffer[ 128 ];
return generic_error_category_message( ev, buffer, sizeof( buffer ) );
}
#else
// std::strerror is thread-safe on everything else, incl. Windows
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic push
# if __has_warning("-Wdeprecated-declarations")
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
# endif
inline std::string generic_error_category_message( int ev )
{
char const * m = std::strerror( ev );
return m? m: "Unknown error";
}
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
if( len == 0 )
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_NOEXCEPT:
error_category( detail::generic_category_id )
{
return buffer;
}
if( len == 1 )
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
{
buffer[0] = 0;
return buffer;
return "generic";
}
char const * m = std::strerror( ev );
std::string message( int ev ) const BOOST_OVERRIDE;
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
};
if( m == 0 ) return "Unknown error";
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic pop
#endif
std::strncpy( buffer, m, len - 1 );
buffer[ len-1 ] = 0;
// generic_error_category::message
return buffer;
inline char const * generic_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return generic_error_category_message( ev, buffer, len );
}
# if defined( BOOST_MSVC )
# pragma warning( pop )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic pop
# endif
inline std::string generic_error_category::message( int ev ) const
{
return generic_error_category_message( ev );
}
} // namespace detail
// generic_category()
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct BOOST_SYMBOL_VISIBLE generic_cat_holder
{
static constexpr generic_error_category instance{};
};
// Before C++17 it was mandatory to redeclare all static constexpr
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class T> constexpr generic_error_category generic_cat_holder<T>::instance;
#endif
} // namespace detail
constexpr error_category const & generic_category() BOOST_NOEXCEPT
{
return detail::generic_cat_holder<void>::instance;
}
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline error_category const & generic_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & generic_category() BOOST_NOEXCEPT
{
static const detail::generic_error_category instance;
return instance;
}
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
// deprecated synonyms
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
BOOST_SYSTEM_DEPRECATED("please use generic_category()") inline const error_category & get_generic_category() { return generic_category(); }
BOOST_SYSTEM_DEPRECATED("please use generic_category()") inline const error_category & get_posix_category() { return generic_category(); }
BOOST_SYSTEM_DEPRECATED("please use generic_category()") static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
BOOST_SYSTEM_DEPRECATED("please use generic_category()") static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
#endif
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,108 @@
#ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED
// Implementation of generic_error_category_message
//
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/config.hpp>
#include <string>
#include <cstring>
namespace boost
{
namespace system
{
namespace detail
{
#if defined(__GLIBC__)
// glibc has two incompatible strerror_r definitions
inline char const * strerror_r_helper( char const * r, char const * ) BOOST_NOEXCEPT
{
return r;
}
inline char const * strerror_r_helper( int r, char const * buffer ) BOOST_NOEXCEPT
{
return r == 0? buffer: "Unknown error";
}
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
}
inline std::string generic_error_category_message( int ev )
{
char buffer[ 128 ];
return generic_error_category_message( ev, buffer, sizeof( buffer ) );
}
#else // #if defined(__GLIBC__)
// std::strerror is thread-safe on everything else, incl. Windows
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic push
# if __has_warning("-Wdeprecated-declarations")
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
# endif
inline std::string generic_error_category_message( int ev )
{
char const * m = std::strerror( ev );
return m? m: "Unknown error";
}
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
char const * m = std::strerror( ev );
if( m == 0 ) return "Unknown error";
std::strncpy( buffer, m, len - 1 );
buffer[ len-1 ] = 0;
return buffer;
}
# if defined( BOOST_MSVC )
# pragma warning( pop )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic pop
# endif
#endif // #if defined(__GLIBC__)
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_GENERIC_CATEGORY_MESSAGE_HPP_INCLUDED

View File

@ -1,5 +1,6 @@
// POSIX-specific implementation details of system_error_category
//
#ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
@ -7,6 +8,8 @@
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/errc.hpp>
namespace boost
{
@ -113,20 +116,10 @@ inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
return false;
}
inline error_condition system_category_default_error_condition_posix( int ev ) BOOST_NOEXCEPT
{
if( is_generic_value( ev ) )
{
return error_condition( ev, generic_category() );
}
else
{
return error_condition( ev, system_category() );
}
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_GENERIC_VALUE_HPP_INCLUDED

View File

@ -0,0 +1,110 @@
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace system
{
namespace detail
{
// system_error_category
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
error_category( detail::system_category_id )
{
}
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
{
return "system";
}
error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
std::string message( int ev ) const BOOST_OVERRIDE;
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
};
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic pop
#endif
} // namespace detail
// system_category()
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct BOOST_SYMBOL_VISIBLE system_cat_holder
{
static constexpr system_error_category instance{};
};
// Before C++17 it was mandatory to redeclare all static constexpr
#if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
template<class T> constexpr system_error_category system_cat_holder<T>::instance;
#endif
} // namespace detail
constexpr error_category const & system_category() BOOST_NOEXCEPT
{
return detail::system_cat_holder<void>::instance;
}
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & system_category() BOOST_NOEXCEPT
{
static const detail::system_error_category instance;
return instance;
}
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
// deprecated synonyms
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
BOOST_SYSTEM_DEPRECATED("please use system_category()") inline const error_category & get_system_category() { return system_category(); }
BOOST_SYSTEM_DEPRECATED("please use system_category()") static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
#endif
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,146 @@
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED
// Copyright Beman Dawes 2002, 2006
// Copyright (c) Microsoft Corporation 2014
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/errc.hpp>
#include <boost/winapi/error_codes.hpp>
#include <boost/config.hpp>
//
namespace boost
{
namespace system
{
namespace detail
{
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
{
// When using the Windows Runtime, most system errors are reported as HRESULTs.
// We want to map the common Win32 errors to their equivalent error condition,
// whether or not they are reported via an HRESULT.
#define BOOST_SYSTEM_FAILED(hr) ((hr) < 0)
#define BOOST_SYSTEM_HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
#define BOOST_SYSTEM_HRESULT_CODE(hr) ((hr) & 0xFFFF)
#define BOOST_SYSTEM_FACILITY_WIN32 7
if( BOOST_SYSTEM_FAILED( ev ) && BOOST_SYSTEM_HRESULT_FACILITY( ev ) == BOOST_SYSTEM_FACILITY_WIN32 )
{
ev = BOOST_SYSTEM_HRESULT_CODE( ev );
}
#undef BOOST_SYSTEM_FAILED
#undef BOOST_SYSTEM_HRESULT_FACILITY
#undef BOOST_SYSTEM_HRESULT_CODE
#undef BOOST_SYSTEM_FACILITY_WIN32
using namespace boost::winapi;
using namespace errc;
// Windows system -> posix_errno decode table
// see WinError.h comments for descriptions of errors
switch ( ev )
{
case 0: return success;
case ERROR_ACCESS_DENIED_: return permission_denied;
case ERROR_ALREADY_EXISTS_: return file_exists;
case ERROR_BAD_UNIT_: return no_such_device;
case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
case ERROR_BUSY_: return device_or_resource_busy;
case ERROR_BUSY_DRIVE_: return device_or_resource_busy;
case ERROR_CANNOT_MAKE_: return permission_denied;
case ERROR_CANTOPEN_: return io_error;
case ERROR_CANTREAD_: return io_error;
case ERROR_CANTWRITE_: return io_error;
case ERROR_CONNECTION_ABORTED_: return connection_aborted;
case ERROR_CURRENT_DIRECTORY_: return permission_denied;
case ERROR_DEV_NOT_EXIST_: return no_such_device;
case ERROR_DEVICE_IN_USE_: return device_or_resource_busy;
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_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;
case ERROR_INVALID_ACCESS_: return permission_denied;
case ERROR_INVALID_DRIVE_: return no_such_device;
case ERROR_INVALID_FUNCTION_: return function_not_supported;
case ERROR_INVALID_HANDLE_: return invalid_argument;
case ERROR_INVALID_NAME_: return invalid_argument;
case ERROR_LOCK_VIOLATION_: return no_lock_available;
case ERROR_LOCKED_: return no_lock_available;
case ERROR_NEGATIVE_SEEK_: return invalid_argument;
case ERROR_NOACCESS_: return permission_denied;
case ERROR_NOT_ENOUGH_MEMORY_: return not_enough_memory;
case ERROR_NOT_READY_: return resource_unavailable_try_again;
case ERROR_NOT_SAME_DEVICE_: return cross_device_link;
case ERROR_OPEN_FAILED_: return io_error;
case ERROR_OPEN_FILES_: return device_or_resource_busy;
case ERROR_OPERATION_ABORTED_: return operation_canceled;
case ERROR_OUTOFMEMORY_: return not_enough_memory;
case ERROR_PATH_NOT_FOUND_: return no_such_file_or_directory;
case ERROR_READ_FAULT_: return io_error;
case ERROR_RETRY_: return resource_unavailable_try_again;
case ERROR_SEEK_: return io_error;
case ERROR_SHARING_VIOLATION_: return permission_denied;
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
case ERROR_WRITE_FAULT_: return io_error;
case ERROR_WRITE_PROTECT_: return permission_denied;
case WSAEACCES_: return permission_denied;
case WSAEADDRINUSE_: return address_in_use;
case WSAEADDRNOTAVAIL_: return address_not_available;
case WSAEAFNOSUPPORT_: return address_family_not_supported;
case WSAEALREADY_: return connection_already_in_progress;
case WSAEBADF_: return bad_file_descriptor;
case WSAECONNABORTED_: return connection_aborted;
case WSAECONNREFUSED_: return connection_refused;
case WSAECONNRESET_: return connection_reset;
case WSAEDESTADDRREQ_: return destination_address_required;
case WSAEFAULT_: return bad_address;
case WSAEHOSTUNREACH_: return host_unreachable;
case WSAEINPROGRESS_: return operation_in_progress;
case WSAEINTR_: return interrupted;
case WSAEINVAL_: return invalid_argument;
case WSAEISCONN_: return already_connected;
case WSAEMFILE_: return too_many_files_open;
case WSAEMSGSIZE_: return message_size;
case WSAENAMETOOLONG_: return filename_too_long;
case WSAENETDOWN_: return network_down;
case WSAENETRESET_: return network_reset;
case WSAENETUNREACH_: return network_unreachable;
case WSAENOBUFS_: return no_buffer_space;
case WSAENOPROTOOPT_: return no_protocol_option;
case WSAENOTCONN_: return not_connected;
case WSAENOTSOCK_: return not_a_socket;
case WSAEOPNOTSUPP_: return operation_not_supported;
case WSAEPROTONOSUPPORT_: return protocol_not_supported;
case WSAEPROTOTYPE_: return wrong_protocol_type;
case WSAETIMEDOUT_: return timed_out;
case WSAEWOULDBLOCK_: return operation_would_block;
default: return -1;
}
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_CONDITION_WIN32_HPP_INCLUDED

View File

@ -0,0 +1,83 @@
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 2018, 2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/system_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/generic_category.hpp>
#include <boost/system/api_config.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
#endif
// system_error_category implementation
#if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/system_category_message_win32.hpp>
#include <boost/system/detail/system_category_condition_win32.hpp>
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
int e2 = system_category_condition_win32( ev );
if( e2 == -1 )
{
return error_condition( ev, *this );
}
else
{
return error_condition( e2, generic_category() );
}
}
inline std::string boost::system::detail::system_error_category::message( int ev ) const
{
return system_category_message_win32( ev );
}
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return system_category_message_win32( ev, buffer, len );
}
#else // #if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/generic_category_message.hpp>
#include <boost/system/detail/is_generic_value.hpp>
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
if( is_generic_value( ev ) )
{
return error_condition( ev, generic_category() );
}
else
{
return error_condition( ev, *this );
}
}
inline std::string boost::system::detail::system_error_category::message( int ev ) const
{
return generic_error_category_message( ev );
}
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return generic_error_category_message( ev, buffer, len );
}
#endif // #if defined(BOOST_WINDOWS_API)
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED

View File

@ -0,0 +1,233 @@
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED
// Copyright Beman Dawes 2002, 2006
// Copyright (c) Microsoft Corporation 2014
// Copyright 2018, 2020 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/winapi/error_handling.hpp>
#include <boost/winapi/character_code_conversion.hpp>
#include <boost/winapi/local_memory.hpp>
#include <boost/config.hpp>
#include <cstdio>
//
namespace boost
{
namespace system
{
namespace detail
{
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
{
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# endif
_snprintf( buffer, len - 1, "Unknown error (%d)", ev );
buffer[ len - 1 ] = 0;
return buffer;
# if defined( BOOST_MSVC )
# pragma warning( pop )
# endif
}
#else
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
{
std::snprintf( buffer, len, "Unknown error (%d)", ev );
return buffer;
}
#endif
inline boost::winapi::UINT_ message_cp_win32()
{
#if defined(BOOST_SYSTEM_USE_UTF8)
return boost::winapi::CP_UTF8_;
#else
return boost::winapi::CP_ACP_;
#endif
}
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
boost::winapi::UINT_ const code_page = message_cp_win32();
int r = 0;
#if !defined(BOOST_NO_ANSI_APIS)
if( code_page == boost::winapi::CP_ACP_ )
{
using namespace boost::winapi;
DWORD_ retval = boost::winapi::FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
buffer,
static_cast<DWORD_>( len ),
NULL
);
r = static_cast<int>( retval );
}
else
#endif
{
using namespace boost::winapi;
wchar_t * lpMsgBuf = 0;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
(LPWSTR_) &lpMsgBuf,
0,
NULL
);
if( retval != 0 )
{
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, buffer, static_cast<int>( len ), NULL, NULL );
boost::winapi::LocalFree( lpMsgBuf );
if ( r != 0 ) --r; // exclude null terminator
}
}
if( r == 0 )
{
return unknown_message_win32( ev, buffer, len );
}
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
{
buffer[ --r ] = 0;
}
if( r > 0 && buffer[ r-1 ] == '.' )
{
buffer[ --r ] = 0;
}
return buffer;
}
struct local_free
{
void * p_;
~local_free()
{
boost::winapi::LocalFree( p_ );
}
};
inline std::string unknown_message_win32( int ev )
{
char buffer[ 38 ];
return unknown_message_win32( ev, buffer, sizeof( buffer ) );
}
inline std::string system_category_message_win32( int ev )
{
using namespace boost::winapi;
wchar_t * lpMsgBuf = 0;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
(LPWSTR_) &lpMsgBuf,
0,
NULL
);
if( retval == 0 )
{
return unknown_message_win32( ev );
}
local_free lf_ = { lpMsgBuf };
(void)lf_;
UINT_ const code_page = message_cp_win32();
int r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, 0, 0, NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev );
}
std::string buffer( r, char() );
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, &buffer[0], r, NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev );
}
--r; // exclude null terminator
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
{
--r;
}
if( r > 0 && buffer[ r-1 ] == '.' )
{
--r;
}
buffer.resize( r );
return buffer;
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_WIN32_HPP_INCLUDED

View File

@ -1,324 +0,0 @@
// Windows implementation of system_error_category
//
// Copyright Beman Dawes 2002, 2006
// Copyright (c) Microsoft Corporation 2014
// Copyright 2018 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/winapi/error_codes.hpp>
#include <boost/winapi/error_handling.hpp>
#include <boost/winapi/character_code_conversion.hpp>
#include <boost/winapi/local_memory.hpp>
#include <cstdio>
//
namespace boost
{
namespace system
{
namespace detail
{
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
{
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# endif
_snprintf( buffer, len - 1, "Unknown error (%d)", ev );
buffer[ len - 1 ] = 0;
return buffer;
# if defined( BOOST_MSVC )
# pragma warning( pop )
# endif
}
#else
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
{
std::snprintf( buffer, len, "Unknown error (%d)", ev );
return buffer;
}
#endif
inline boost::winapi::UINT_ message_cp_win32()
{
#if defined(BOOST_SYSTEM_USE_UTF8)
return boost::winapi::CP_UTF8_;
#else
return boost::winapi::CP_ACP_;
#endif
}
inline char const * system_category_message_win32( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
#if defined(__GNUC__)
# define BOOST_SYSTEM_ALLOCA __builtin_alloca
#else
# define BOOST_SYSTEM_ALLOCA _alloca
#endif
wchar_t * wbuffer = static_cast<wchar_t*>( BOOST_SYSTEM_ALLOCA( len * sizeof( wchar_t ) ) );
#undef BOOST_SYSTEM_ALLOCA
using namespace boost::winapi;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
wbuffer,
static_cast<DWORD_>( len ),
NULL
);
if( retval == 0 )
{
return unknown_message_win32( ev, buffer, len );
}
UINT_ const code_page = message_cp_win32();
int r = boost::winapi::WideCharToMultiByte( code_page, 0, wbuffer, -1, buffer, static_cast<int>( len ), NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev, buffer, len );
}
--r; // exclude null terminator
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
{
buffer[ --r ] = 0;
}
if( r > 0 && buffer[ r-1 ] == '.' )
{
buffer[ --r ] = 0;
}
return buffer;
}
struct local_free
{
void * p_;
~local_free()
{
boost::winapi::LocalFree( p_ );
}
};
inline std::string unknown_message_win32( int ev )
{
char buffer[ 38 ];
return unknown_message_win32( ev, buffer, sizeof( buffer ) );
}
inline std::string system_category_message_win32( int ev )
{
using namespace boost::winapi;
wchar_t * lpMsgBuf = 0;
DWORD_ retval = boost::winapi::FormatMessageW(
FORMAT_MESSAGE_ALLOCATE_BUFFER_ | FORMAT_MESSAGE_FROM_SYSTEM_ | FORMAT_MESSAGE_IGNORE_INSERTS_,
NULL,
ev,
MAKELANGID_( LANG_NEUTRAL_, SUBLANG_DEFAULT_ ), // Default language
(LPWSTR_) &lpMsgBuf,
0,
NULL
);
if( retval == 0 )
{
return unknown_message_win32( ev );
}
local_free lf_ = { lpMsgBuf };
(void)lf_;
UINT_ const code_page = message_cp_win32();
int r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, 0, 0, NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev );
}
std::string buffer( r, char() );
r = boost::winapi::WideCharToMultiByte( code_page, 0, lpMsgBuf, -1, &buffer[0], r, NULL, NULL );
if( r == 0 )
{
return unknown_message_win32( ev );
}
--r; // exclude null terminator
while( r > 0 && ( buffer[ r-1 ] == '\n' || buffer[ r-1 ] == '\r' ) )
{
--r;
}
if( r > 0 && buffer[ r-1 ] == '.' )
{
--r;
}
buffer.resize( r );
return buffer;
}
inline error_condition system_category_default_error_condition_win32( int ev ) BOOST_NOEXCEPT
{
// When using the Windows Runtime, most system errors are reported as HRESULTs.
// We want to map the common Win32 errors to their equivalent error condition,
// whether or not they are reported via an HRESULT.
#define BOOST_SYSTEM_FAILED(hr) ((hr) < 0)
#define BOOST_SYSTEM_HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1fff)
#define BOOST_SYSTEM_HRESULT_CODE(hr) ((hr) & 0xFFFF)
#define BOOST_SYSTEM_FACILITY_WIN32 7
if( BOOST_SYSTEM_FAILED( ev ) && BOOST_SYSTEM_HRESULT_FACILITY( ev ) == BOOST_SYSTEM_FACILITY_WIN32 )
{
ev = BOOST_SYSTEM_HRESULT_CODE( ev );
}
#undef BOOST_SYSTEM_FAILED
#undef BOOST_SYSTEM_HRESULT_FACILITY
#undef BOOST_SYSTEM_HRESULT_CODE
#undef BOOST_SYSTEM_FACILITY_WIN32
using namespace boost::winapi;
using namespace errc;
// Windows system -> posix_errno decode table
// see WinError.h comments for descriptions of errors
switch ( ev )
{
case 0: return make_error_condition( success );
case ERROR_ACCESS_DENIED_: return make_error_condition( permission_denied );
case ERROR_ALREADY_EXISTS_: return make_error_condition( file_exists );
case ERROR_BAD_UNIT_: return make_error_condition( no_such_device );
case ERROR_BUFFER_OVERFLOW_: return make_error_condition( filename_too_long );
case ERROR_BUSY_: return make_error_condition( device_or_resource_busy );
case ERROR_BUSY_DRIVE_: return make_error_condition( device_or_resource_busy );
case ERROR_CANNOT_MAKE_: return make_error_condition( permission_denied );
case ERROR_CANTOPEN_: return make_error_condition( io_error );
case ERROR_CANTREAD_: return make_error_condition( io_error );
case ERROR_CANTWRITE_: return make_error_condition( io_error );
case ERROR_CURRENT_DIRECTORY_: return make_error_condition( permission_denied );
case ERROR_DEV_NOT_EXIST_: return make_error_condition( no_such_device );
case ERROR_DEVICE_IN_USE_: return make_error_condition( device_or_resource_busy );
case ERROR_DIR_NOT_EMPTY_: return make_error_condition( directory_not_empty );
case ERROR_DIRECTORY_: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid"
case ERROR_DISK_FULL_: return make_error_condition( no_space_on_device );
case ERROR_FILE_EXISTS_: return make_error_condition( file_exists );
case ERROR_FILE_NOT_FOUND_: return make_error_condition( no_such_file_or_directory );
case ERROR_HANDLE_DISK_FULL_: return make_error_condition( no_space_on_device );
case ERROR_INVALID_ACCESS_: return make_error_condition( permission_denied );
case ERROR_INVALID_DRIVE_: return make_error_condition( no_such_device );
case ERROR_INVALID_FUNCTION_: return make_error_condition( function_not_supported );
case ERROR_INVALID_HANDLE_: return make_error_condition( invalid_argument );
case ERROR_INVALID_NAME_: return make_error_condition( invalid_argument );
case ERROR_LOCK_VIOLATION_: return make_error_condition( no_lock_available );
case ERROR_LOCKED_: return make_error_condition( no_lock_available );
case ERROR_NEGATIVE_SEEK_: return make_error_condition( invalid_argument );
case ERROR_NOACCESS_: return make_error_condition( permission_denied );
case ERROR_NOT_ENOUGH_MEMORY_: return make_error_condition( not_enough_memory );
case ERROR_NOT_READY_: return make_error_condition( resource_unavailable_try_again );
case ERROR_NOT_SAME_DEVICE_: return make_error_condition( cross_device_link );
case ERROR_OPEN_FAILED_: return make_error_condition( io_error );
case ERROR_OPEN_FILES_: return make_error_condition( device_or_resource_busy );
case ERROR_OPERATION_ABORTED_: return make_error_condition( operation_canceled );
case ERROR_OUTOFMEMORY_: return make_error_condition( not_enough_memory );
case ERROR_PATH_NOT_FOUND_: return make_error_condition( no_such_file_or_directory );
case ERROR_READ_FAULT_: return make_error_condition( io_error );
case ERROR_RETRY_: return make_error_condition( resource_unavailable_try_again );
case ERROR_SEEK_: return make_error_condition( io_error );
case ERROR_SHARING_VIOLATION_: return make_error_condition( permission_denied );
case ERROR_TOO_MANY_OPEN_FILES_: return make_error_condition( too_many_files_open );
case ERROR_WRITE_FAULT_: return make_error_condition( io_error );
case ERROR_WRITE_PROTECT_: return make_error_condition( permission_denied );
case WSAEACCES_: return make_error_condition( permission_denied );
case WSAEADDRINUSE_: return make_error_condition( address_in_use );
case WSAEADDRNOTAVAIL_: return make_error_condition( address_not_available );
case WSAEAFNOSUPPORT_: return make_error_condition( address_family_not_supported );
case WSAEALREADY_: return make_error_condition( connection_already_in_progress );
case WSAEBADF_: return make_error_condition( bad_file_descriptor );
case WSAECONNABORTED_: return make_error_condition( connection_aborted );
case WSAECONNREFUSED_: return make_error_condition( connection_refused );
case WSAECONNRESET_: return make_error_condition( connection_reset );
case WSAEDESTADDRREQ_: return make_error_condition( destination_address_required );
case WSAEFAULT_: return make_error_condition( bad_address );
case WSAEHOSTUNREACH_: return make_error_condition( host_unreachable );
case WSAEINPROGRESS_: return make_error_condition( operation_in_progress );
case WSAEINTR_: return make_error_condition( interrupted );
case WSAEINVAL_: return make_error_condition( invalid_argument );
case WSAEISCONN_: return make_error_condition( already_connected );
case WSAEMFILE_: return make_error_condition( too_many_files_open );
case WSAEMSGSIZE_: return make_error_condition( message_size );
case WSAENAMETOOLONG_: return make_error_condition( filename_too_long );
case WSAENETDOWN_: return make_error_condition( network_down );
case WSAENETRESET_: return make_error_condition( network_reset );
case WSAENETUNREACH_: return make_error_condition( network_unreachable );
case WSAENOBUFS_: return make_error_condition( no_buffer_space );
case WSAENOPROTOOPT_: return make_error_condition( no_protocol_option );
case WSAENOTCONN_: return make_error_condition( not_connected );
case WSAENOTSOCK_: return make_error_condition( not_a_socket );
case WSAEOPNOTSUPP_: return make_error_condition( operation_not_supported );
case WSAEPROTONOSUPPORT_: return make_error_condition( protocol_not_supported );
case WSAEPROTOTYPE_: return make_error_condition( wrong_protocol_type );
case WSAETIMEDOUT_: return make_error_condition( timed_out );
case WSAEWOULDBLOCK_: return make_error_condition( operation_would_block );
default: return error_condition( ev, system_category() );
}
}
} // namespace detail
} // namespace system
} // namespace boost

View File

@ -0,0 +1,59 @@
#ifndef BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
namespace boost
{
namespace system
{
class error_code;
} // namespace system
// boost::throws()
namespace detail
{
// Misuse of the error_code object is turned into a noisy failure by
// poisoning the reference. This particular implementation doesn't
// produce warnings or errors from popular compilers, is very efficient
// (as determined by inspecting generated code), and does not suffer
// from order of initialization problems. In practice, it also seems
// cause user function error handling implementation errors to be detected
// very early in the development cycle.
inline system::error_code* throws()
{
// See github.com/boostorg/system/pull/12 by visigoth for why the return
// is poisoned with nonzero rather than (0). A test, test_throws_usage(),
// has been added to error_code_test.cpp, and as visigoth mentioned it
// fails on clang for release builds with a return of 0 but works fine
// with (1).
// Since the undefined behavior sanitizer (-fsanitize=undefined) does not
// allow a reference to be formed to the unaligned address of (1), we use
// (8) instead.
return reinterpret_cast<system::error_code*>(8);
}
} // namespace detail
inline system::error_code& throws()
{
return *detail::throws();
}
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_THROWS_HPP_INCLUDED

View File

@ -1,3 +1,6 @@
#ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED
// Support for interoperability between Boost.System and <system_error>
//
// Copyright 2018 Peter Dimov
@ -7,9 +10,14 @@
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/detail/generic_category.hpp>
#include <system_error>
#include <map>
#include <memory>
#include <mutex>
//
@ -30,47 +38,87 @@ private:
public:
explicit std_category( boost::system::error_category const * pc ): pc_( pc )
explicit std_category( boost::system::error_category const * pc, unsigned 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
_Addr = id;
#endif
}
}
virtual const char * name() const BOOST_NOEXCEPT
const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
{
return pc_->name();
}
virtual std::string message( int ev ) const
std::string message( int ev ) const BOOST_OVERRIDE
{
return pc_->message( ev );
}
virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE
{
return pc_->default_error_condition( ev );
}
virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT;
virtual bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT;
bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
};
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
#endif
struct cat_ptr_less
{
bool operator()( boost::system::error_category const * p1, boost::system::error_category const * p2 ) const BOOST_NOEXCEPT
{
return *p1 < *p2;
}
};
inline std::error_category const & to_std_category( boost::system::error_category const & cat )
{
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category> > map_type;
static map_type map_;
map_type::iterator i = map_.find( &cat );
if( i == map_.end() )
if( cat.id_ == boost::system::detail::system_category_id )
{
std::unique_ptr<std_category> p( new std_category( &cat ) );
std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );
i = r.first;
static const std_category system_instance( &cat, 0x1F4D7 );
return system_instance;
}
else if( cat.id_ == boost::system::detail::generic_category_id )
{
static const std_category generic_instance( &cat, 0x1F4D3 );
return generic_instance;
}
else
{
typedef std::map< boost::system::error_category const *, std::unique_ptr<std_category>, cat_ptr_less > map_type;
return *i->second;
static map_type map_;
static std::mutex map_mx_;
std::lock_guard<std::mutex> guard( map_mx_ );
map_type::iterator i = map_.find( &cat );
if( i == map_.end() )
{
std::unique_ptr<std_category> p( new std_category( &cat, 0 ) );
std::pair<map_type::iterator, bool> r = map_.insert( map_type::value_type( &cat, std::move( p ) ) );
i = r.first;
}
return *i->second;
}
}
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT
@ -139,3 +187,5 @@ inline bool std_category::equivalent( const std::error_code & code, int conditio
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_TO_STD_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,50 @@
#ifndef BOOST_SYSTEM_ERRC_HPP_INCLUDED
#define BOOST_SYSTEM_ERRC_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 2018, 2020
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/errc.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/generic_category.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace system
{
// make_* functions for errc::errc_t
namespace errc
{
// explicit conversion:
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
{
return error_code( e, generic_category() );
}
// implicit conversion:
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
{
return error_condition( e, generic_category() );
}
} // namespace errc
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_ERRC_HPP_INCLUDED

View File

@ -0,0 +1,13 @@
#ifndef BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/error_category.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#endif // #ifndef BOOST_SYSTEM_ERROR_CATEGORY_HPP_INCLUDED

View File

@ -10,25 +10,14 @@
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/api_config.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/error_category.hpp>
#include <boost/system/error_condition.hpp>
#include <boost/system/errc.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/system/system_category.hpp>
#include <boost/system/detail/throws.hpp>
#include <boost/config.hpp>
#include <ostream>
#include <string>
#include <functional>
#include <cstring>
// TODO: undef these macros if not already defined
#include <boost/cerrno.hpp>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
# include <system_error>
#endif
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
#endif
namespace boost
{
@ -36,706 +25,8 @@ namespace boost
namespace system
{
class error_code; // values defined by the operating system
class error_condition; // portable generic values defined below, but ultimately
// based on the POSIX standard
// "Concept" helpers
template<class T> struct is_error_code_enum
{
static const bool value = false;
};
template<class T> struct is_error_condition_enum
{
static const bool value = false;
};
// Generic error_conditions
namespace errc
{
enum errc_t
{
success = 0,
address_family_not_supported = EAFNOSUPPORT,
address_in_use = EADDRINUSE,
address_not_available = EADDRNOTAVAIL,
already_connected = EISCONN,
argument_list_too_long = E2BIG,
argument_out_of_domain = EDOM,
bad_address = EFAULT,
bad_file_descriptor = EBADF,
bad_message = EBADMSG,
broken_pipe = EPIPE,
connection_aborted = ECONNABORTED,
connection_already_in_progress = EALREADY,
connection_refused = ECONNREFUSED,
connection_reset = ECONNRESET,
cross_device_link = EXDEV,
destination_address_required = EDESTADDRREQ,
device_or_resource_busy = EBUSY,
directory_not_empty = ENOTEMPTY,
executable_format_error = ENOEXEC,
file_exists = EEXIST,
file_too_large = EFBIG,
filename_too_long = ENAMETOOLONG,
function_not_supported = ENOSYS,
host_unreachable = EHOSTUNREACH,
identifier_removed = EIDRM,
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
interrupted = EINTR,
invalid_argument = EINVAL,
invalid_seek = ESPIPE,
io_error = EIO,
is_a_directory = EISDIR,
message_size = EMSGSIZE,
network_down = ENETDOWN,
network_reset = ENETRESET,
network_unreachable = ENETUNREACH,
no_buffer_space = ENOBUFS,
no_child_process = ECHILD,
no_link = ENOLINK,
no_lock_available = ENOLCK,
no_message_available = ENODATA,
no_message = ENOMSG,
no_protocol_option = ENOPROTOOPT,
no_space_on_device = ENOSPC,
no_stream_resources = ENOSR,
no_such_device_or_address = ENXIO,
no_such_device = ENODEV,
no_such_file_or_directory = ENOENT,
no_such_process = ESRCH,
not_a_directory = ENOTDIR,
not_a_socket = ENOTSOCK,
not_a_stream = ENOSTR,
not_connected = ENOTCONN,
not_enough_memory = ENOMEM,
not_supported = ENOTSUP,
operation_canceled = ECANCELED,
operation_in_progress = EINPROGRESS,
operation_not_permitted = EPERM,
operation_not_supported = EOPNOTSUPP,
operation_would_block = EWOULDBLOCK,
owner_dead = EOWNERDEAD,
permission_denied = EACCES,
protocol_error = EPROTO,
protocol_not_supported = EPROTONOSUPPORT,
read_only_file_system = EROFS,
resource_deadlock_would_occur = EDEADLK,
resource_unavailable_try_again = EAGAIN,
result_out_of_range = ERANGE,
state_not_recoverable = ENOTRECOVERABLE,
stream_timeout = ETIME,
text_file_busy = ETXTBSY,
timed_out = ETIMEDOUT,
too_many_files_open_in_system = ENFILE,
too_many_files_open = EMFILE,
too_many_links = EMLINK,
too_many_symbolic_link_levels = ELOOP,
value_too_large = EOVERFLOW,
wrong_protocol_type = EPROTOTYPE
};
} // namespace errc
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
namespace posix = errc;
namespace posix_error = errc;
#endif
template<> struct is_error_condition_enum<errc::errc_t>
{
static const bool value = true;
};
// class error_category
#ifdef BOOST_MSVC
#pragma warning( push )
// 'this' : used in base member initializer list
#pragma warning( disable: 4355 )
#endif
std::size_t hash_value( error_code const & ec );
class BOOST_SYMBOL_VISIBLE error_category
{
private:
friend std::size_t hash_value( error_code const & ec );
#if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
public:
error_category( error_category const & ) = delete;
error_category& operator=( error_category const & ) = delete;
#else
private:
error_category( error_category const & );
error_category& operator=( error_category const & );
#endif
private:
boost::ulong_long_type id_;
protected:
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
~error_category() = default;
#else
// We'd like to make the destructor protected, to make code that deletes
// an error_category* not compile; unfortunately, doing the below makes
// the destructor user-provided and hence breaks use after main, as the
// categories may get destroyed before code that uses them
// ~error_category() {}
#endif
BOOST_SYSTEM_CONSTEXPR error_category() BOOST_NOEXCEPT: id_( 0 )
{
}
explicit BOOST_SYSTEM_CONSTEXPR error_category( boost::ulong_long_type id ) BOOST_NOEXCEPT: id_( id )
{
}
public:
virtual const char * name() const BOOST_NOEXCEPT = 0;
virtual error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
virtual bool equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT;
virtual bool equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT;
virtual std::string message( int ev ) const = 0;
virtual char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
virtual bool failed( int ev ) const BOOST_NOEXCEPT;
BOOST_SYSTEM_CONSTEXPR bool operator==( const error_category & rhs ) const BOOST_NOEXCEPT
{
return rhs.id_ == 0? this == &rhs: id_ == rhs.id_;
}
BOOST_SYSTEM_CONSTEXPR bool operator!=( const error_category & rhs ) const BOOST_NOEXCEPT
{
return !( *this == rhs );
}
BOOST_SYSTEM_CONSTEXPR bool operator<( const error_category & rhs ) const BOOST_NOEXCEPT
{
if( id_ < rhs.id_ )
{
return true;
}
if( id_ > rhs.id_ )
{
return false;
}
if( rhs.id_ != 0 )
{
return false; // equal
}
return std::less<error_category const *>()( this, &rhs );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_category const & () const;
#endif
};
#ifdef BOOST_MSVC
#pragma warning( pop )
#endif
// predefined error categories
namespace detail
{
class BOOST_SYMBOL_VISIBLE generic_error_category: public error_category
{
public:
// clang++ 3.8 and below: initialization of const object
// requires a user-provided default constructor
BOOST_SYSTEM_CONSTEXPR generic_error_category() BOOST_NOEXCEPT:
error_category( ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D )
{
}
const char * name() const BOOST_NOEXCEPT
{
return "generic";
}
std::string message( int ev ) const;
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
};
class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
error_category( ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B )
{
}
const char * name() const BOOST_NOEXCEPT
{
return "system";
}
error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT;
std::string message( int ev ) const;
char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT;
};
} // namespace detail
// generic_category(), system_category()
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct cat_holder
{
BOOST_SYSTEM_REQUIRE_CONST_INIT static constexpr system_error_category system_category_instance{};
BOOST_SYSTEM_REQUIRE_CONST_INIT static constexpr generic_error_category generic_category_instance{};
};
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT constexpr system_error_category cat_holder<T>::system_category_instance;
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT constexpr generic_error_category cat_holder<T>::generic_category_instance;
} // namespace detail
constexpr error_category const & system_category() BOOST_NOEXCEPT
{
return detail::cat_holder<void>::system_category_instance;
}
constexpr error_category const & generic_category() BOOST_NOEXCEPT
{
return detail::cat_holder<void>::generic_category_instance;
}
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
inline error_category const & system_category() BOOST_NOEXCEPT
{
static const detail::system_error_category system_category_instance;
return system_category_instance;
}
inline error_category const & generic_category() BOOST_NOEXCEPT
{
static const detail::generic_error_category generic_category_instance;
return generic_category_instance;
}
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
// deprecated synonyms
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
inline const error_category & get_system_category() { return system_category(); }
inline const error_category & get_generic_category() { return generic_category(); }
inline const error_category & get_posix_category() { return generic_category(); }
static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED = generic_category();
static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category();
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
#endif
// enable_if
namespace detail
{
template<bool C, class T = void> struct enable_if
{
typedef T type;
};
template<class T> struct enable_if<false, T>
{
};
// failed_impl
#if !defined(BOOST_SYSTEM_HAS_CONSTEXPR)
inline bool failed_impl( int ev, error_category const & cat )
{
return cat.failed( ev );
}
#else
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
{
if( cat == system_category() || cat == generic_category() )
{
return ev != 0;
}
else
{
return cat.failed( ev );
}
}
#endif
} // namespace detail
// class error_condition
// error_conditions are portable, error_codes are system or library specific
class error_condition
{
private:
int val_;
bool failed_;
error_category const * cat_;
public:
// constructors:
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
val_( 0 ), failed_( false ), cat_( &generic_category() )
{
}
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
{
}
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type* = 0) BOOST_NOEXCEPT
{
*this = make_error_condition( e );
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
{
val_ = val;
failed_ = detail::failed_impl( val, cat );
cat_ = &cat;
}
template<typename ErrorConditionEnum>
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
operator=( ErrorConditionEnum val ) BOOST_NOEXCEPT
{
*this = make_error_condition( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
{
val_ = 0;
failed_ = false;
cat_ = &generic_category();
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
{
return val_;
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
{
return *cat_;
}
std::string message() const
{
return cat_->message( value() );
}
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return cat_->message( value(), buffer, len );
}
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
{
return failed_;
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
{
return failed_;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
{
return failed_? unspecified_bool_true: 0;
}
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
{
return !failed_;
}
#endif
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_condition () const
{
return std::error_condition( value(), category() );
}
#endif
};
// class error_code
// We want error_code to be a value type that can be copied without slicing
// and without requiring heap allocation, but we also want it to have
// polymorphic behavior based on the error category. This is achieved by
// abstract base class error_category supplying the polymorphic behavior,
// and error_code containing a pointer to an object of a type derived
// from error_category.
class error_code
{
private:
int val_;
bool failed_;
const error_category * cat_;
public:
// constructors:
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
val_( 0 ), failed_( false ), cat_( &system_category() )
{
}
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
{
}
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT
{
*this = make_error_code( e );
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
{
val_ = val;
failed_ = detail::failed_impl( val, cat );
cat_ = &cat;
}
template<typename ErrorCodeEnum>
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
operator=( ErrorCodeEnum val ) BOOST_NOEXCEPT
{
*this = make_error_code( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
{
val_ = 0;
failed_ = false;
cat_ = &system_category();
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
{
return val_;
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
{
return *cat_;
}
error_condition default_error_condition() const BOOST_NOEXCEPT
{
return cat_->default_error_condition( value() );
}
std::string message() const
{
return cat_->message( value() );
}
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return cat_->message( value(), buffer, len );
}
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
{
return failed_;
}
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
{
return failed_;
}
#else
typedef void (*unspecified_bool_type)();
static void unspecified_bool_true() {}
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
{
return failed_? unspecified_bool_true: 0;
}
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
{
return !failed_;
}
#endif
// relationals:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return lhs.val_ == rhs.val_ && *lhs.cat_ == *rhs.cat_;
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return *lhs.cat_ < *rhs.cat_ || ( *lhs.cat_ == *rhs.cat_ && lhs.val_ < rhs.val_ );
}
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
operator std::error_code () const
{
return std::error_code( value(), category() );
}
#endif
};
} // namespace system
// boost::throws()
namespace detail
{
// Misuse of the error_code object is turned into a noisy failure by
// poisoning the reference. This particular implementation doesn't
// produce warnings or errors from popular compilers, is very efficient
// (as determined by inspecting generated code), and does not suffer
// from order of initialization problems. In practice, it also seems
// cause user function error handling implementation errors to be detected
// very early in the development cycle.
inline system::error_code* throws()
{
// See github.com/boostorg/system/pull/12 by visigoth for why the return
// is poisoned with nonzero rather than (0). A test, test_throws_usage(),
// has been added to error_code_test.cpp, and as visigoth mentioned it
// fails on clang for release builds with a return of 0 but works fine
// with (1).
// Since the undefined behavior sanitizer (-fsanitize=undefined) does not
// allow a reference to be formed to the unaligned address of (1), we use
// (8) instead.
return reinterpret_cast<system::error_code*>(8);
}
} // namespace detail
inline system::error_code& throws()
{
return *detail::throws();
}
// non-member functions of error_code and error_condition
namespace system
{
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
return !( lhs == rhs );
}
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_condition & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return !( lhs == rhs );
}
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
{
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
@ -756,201 +47,8 @@ inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BO
return !( lhs == rhs );
}
template <class charT, class traits>
inline std::basic_ostream<charT,traits>&
operator<< (std::basic_ostream<charT,traits>& os, error_code ec)
{
os << ec.category().name() << ':' << ec.value();
return os;
}
inline std::size_t hash_value( error_code const & ec )
{
error_category const & cat = ec.category();
boost::ulong_long_type id = cat.id_;
if( id == 0 )
{
id = reinterpret_cast<boost::ulong_long_type>( &cat );
}
boost::ulong_long_type hv = ( boost::ulong_long_type( 0xCBF29CE4 ) << 32 ) + 0x84222325;
boost::ulong_long_type const prime = ( boost::ulong_long_type( 0x00000100 ) << 32 ) + 0x000001B3;
// id
hv ^= id;
hv *= prime;
// value
hv ^= static_cast<unsigned>( ec.value() );
hv *= prime;
return static_cast<std::size_t>( hv );
}
// make_* functions for errc::errc_t
namespace errc
{
// explicit conversion:
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
{
return error_code( e, generic_category() );
}
// implicit conversion:
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
{
return error_condition( e, generic_category() );
}
} // namespace errc
// error_category default implementation
inline error_condition error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return error_condition( ev, *this );
}
inline bool error_category::equivalent( int code, const error_condition & condition ) const BOOST_NOEXCEPT
{
return default_error_condition( code ) == condition;
}
inline bool error_category::equivalent( const error_code & code, int condition ) const BOOST_NOEXCEPT
{
return *this == code.category() && code.value() == condition;
}
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
try
#endif
{
std::string m = this->message( ev );
# if defined( BOOST_MSVC )
# pragma warning( push )
# pragma warning( disable: 4996 )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic push
# if __has_warning("-Wdeprecated-declarations")
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
# endif
std::strncpy( buffer, m.c_str(), len - 1 );
buffer[ len-1 ] = 0;
# if defined( BOOST_MSVC )
# pragma warning( pop )
# elif defined(__clang__) && defined(__has_warning)
# pragma clang diagnostic pop
# endif
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
catch( ... )
{
return "Message text unavailable";
}
#endif
}
inline bool error_category::failed( int ev ) const BOOST_NOEXCEPT
{
return ev != 0;
}
} // namespace system
} // namespace boost
// generic_error_category implementation
#include <boost/system/detail/generic_category.hpp>
inline std::string boost::system::detail::generic_error_category::message( int ev ) const
{
return generic_error_category_message( ev );
}
inline char const * boost::system::detail::generic_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return generic_error_category_message( ev, buffer, len );
}
// system_error_category implementation
#if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/system_category_win32.hpp>
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return system_category_default_error_condition_win32( ev );
}
inline std::string boost::system::detail::system_error_category::message( int ev ) const
{
return system_category_message_win32( ev );
}
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return system_category_message_win32( ev, buffer, len );
}
#else // #if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/system_category_posix.hpp>
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
{
return system_category_default_error_condition_posix( ev );
}
inline std::string boost::system::detail::system_error_category::message( int ev ) const
{
return generic_error_category_message( ev );
}
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
{
return generic_error_category_message( ev, buffer, len );
}
#endif // #if defined(BOOST_WINDOWS_API)
// interoperability with std::error_code, std::error_condition
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <boost/system/detail/std_interoperability.hpp>
inline boost::system::error_category::operator std::error_category const & () const
{
return boost::system::detail::to_std_category( *this );
}
#endif // #if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED

View File

@ -0,0 +1,13 @@
#ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED
#define BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#endif // #ifndef BOOST_SYSTEM_ERROR_CONDITION_HPP_INCLUDED

View File

@ -0,0 +1,13 @@
#ifndef BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/generic_category.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#endif // #ifndef BOOST_SYSTEM_GENERIC_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,30 @@
#ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
#define BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
namespace boost
{
namespace system
{
class error_code;
template<class T> struct is_error_code_enum
{
static const bool value = false;
};
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED

View File

@ -0,0 +1,30 @@
#ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
#define BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 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
namespace boost
{
namespace system
{
class error_condition;
template<class T> struct is_error_condition_enum
{
static const bool value = false;
};
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED

View File

@ -10,6 +10,13 @@
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
#define BOOST_SYSTEM_LINUX_ERROR_HPP
#include <boost/config/pragma_message.hpp>
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
" If you want it retained, please open an issue in github.com/boostorg/system.")
#endif
// This header is effectively empty for compiles on operating systems where
// it is not applicable.

View File

@ -0,0 +1,14 @@
#ifndef BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/system_category.hpp>
#include <boost/system/detail/system_category_impl.hpp>
#include <boost/system/detail/error_category_impl.hpp>
#endif // #ifndef BOOST_SYSTEM_SYSTEM_CATEGORY_HPP_INCLUDED

View File

@ -47,7 +47,7 @@ namespace boost
virtual ~system_error() BOOST_NOEXCEPT_OR_NOTHROW {}
error_code code() const BOOST_NOEXCEPT { return m_error_code; }
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW;
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
private:
error_code m_error_code;

View File

@ -10,6 +10,13 @@
#ifndef BOOST_SYSTEM_WINDOWS_ERROR_HPP
#define BOOST_SYSTEM_WINDOWS_ERROR_HPP
#include <boost/config/pragma_message.hpp>
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
" If you want it retained, please open an issue in github.com/boostorg/system.")
#endif
// This header is effectively empty for compiles on operating systems where
// it is not applicable.

71
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,71 @@
# Copyright 2018-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()
macro(system_run s1)
string(MAKE_C_IDENTIFIER ${s1} n1)
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)
endmacro()
macro(lib name macro)
add_library(${name} EXCLUDE_FROM_ALL ${ARGN})
target_compile_definitions(${name} PRIVATE $<$<BOOL:BUILD_SHARED_LIBS>:${macro}=1>)
target_link_libraries(${name} PRIVATE Boost::system Boost::config)
endmacro()
set(BOOST_TEST_LINK_LIBRARIES Boost::system Boost::core Boost::static_assert)
boost_test(SOURCES quick.cpp)
system_run(error_code_test.cpp)
system_run(error_code_user_test.cpp)
system_run(system_error_test.cpp)
lib(boost_system_throw_test THROW_DYN_LINK throw_test.cpp)
boost_test(SOURCES dynamic_link_test.cpp LINK_LIBRARIES boost_system_throw_test)
system_run(initialization_test.cpp)
system_run(header_only_test.cpp)
boost_test(SOURCES config_test.cpp)
system_run(std_interop_test.cpp)
system_run(std_mismatch_test.cpp)
lib(boost_system_single_instance_lib1 SINGLE_INSTANCE_DYN_LINK single_instance_1.cpp)
lib(boost_system_single_instance_lib2 SINGLE_INSTANCE_DYN_LINK single_instance_2.cpp)
system_run(single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp)
boost_test(SOURCES single_instance_test.cpp NAME single_instance_test_lib LINK_LIBRARIES boost_system_single_instance_lib1 boost_system_single_instance_lib2)
system_run(before_main_test.cpp)
system_run(constexpr_test.cpp)
system_run(win32_hresult_test.cpp)
system_run(error_category_test.cpp)
system_run(generic_category_test.cpp)
system_run(system_category_test.cpp)
system_run(after_main_test.cpp)
system_run(failed_test.cpp)
system_run(failed_constexpr_test.cpp)
boost_test(SOURCES warnings_test.cpp COMPILE_OPTIONS -Wall -Werror)
lib(boost_system_std_single_instance_lib1 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_1.cpp)
lib(boost_system_std_single_instance_lib2 STD_SINGLE_INSTANCE_DYN_LINK std_single_instance_2.cpp)
system_run(std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp)
boost_test(SOURCES std_single_instance_test.cpp NAME std_single_instance_test_lib LINK_LIBRARIES boost_system_std_single_instance_lib1 boost_system_std_single_instance_lib2)

View File

@ -1,7 +1,7 @@
# Boost System Library test Jamfile
# Copyright Beman Dawes 2003, 2006
# Copyright 2017, 2018 Peter Dimov
# Copyright 2017-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
@ -9,118 +9,46 @@
# See library home page at http://www.boost.org/libs/system
import testing ;
import os ;
project
: requirements
<library>/boost/system//boost_system
;
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
rule cxx03 ( properties * )
{
local result ;
if <toolset>gcc in $(properties)
{
result = <cxxflags>-std=c++98 ; # 4.4 has no 03
}
else if <toolset>clang in $(properties)
{
result = <cxxflags>-std=c++03 ;
}
else
{
result = <build>no ;
}
return $(result) ;
}
rule cxx11 ( properties * )
{
local result ;
if <toolset>gcc in $(properties)
{
result = <cxxflags>-std=c++0x ; # 4.6 has no 11
}
else if <toolset>clang in $(properties)
{
result = <cxxflags>-std=c++11 ;
}
else
{
result = <build>no ;
}
return $(result) ;
}
rule system-run- ( sources + )
{
local result ;
result += [ run $(sources) : : : <link>static : $(sources[1]:B)_static ] ;
result += [ run $(sources) : : : <link>shared : $(sources[1]:B)_shared ] ;
result += [ run $(sources) : : : -<library>/boost/system//boost_system <define>BOOST_ERROR_CODE_HEADER_ONLY : $(sources[1]:B)_header ] ;
return $(result) ;
}
if [ os.environ UBSAN ]
rule system-run ( sources + )
{
rule system-run ( sources + )
{
# The 03/11 tests are ODR violations, no point running them under -fsanitize=undefined
return [ system-run- $(sources) ] ;
}
}
else
{
rule system-run ( sources + )
{
local result = [ system-run- $(sources) ] ;
local result ;
# Test a source file built with -std=c++03 linked with a System library built without -std=c++03
result += [ run $(sources) : : : <link>static <conditional>@cxx03 : $(sources[1]:B)_static_03 ] ;
result += [ run $(sources) : : : <link>shared <conditional>@cxx03 : $(sources[1]:B)_shared_03 ] ;
result += [ run $(sources) ] ;
result += [ run $(sources) : : : <library>/boost/system//boost_system <link>static : $(sources[1]:B)_static ] ;
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 ] ;
# Test a source file built with -std=c++11 linked with a System library built without -std=c++11
result += [ run $(sources) : : : <link>static <conditional>@cxx11 : $(sources[1]:B)_static_11 ] ;
result += [ run $(sources) : : : <link>shared <conditional>@cxx11 : $(sources[1]:B)_shared_11 ] ;
return $(result) ;
}
return $(result) ;
}
system-run error_code_test.cpp ;
system-run error_code_user_test.cpp ;
system-run system_error_test.cpp ;
run dynamic_link_test.cpp throw_test : : : <link>shared : throw_test_shared ;
lib throw_test : throw_test.cpp : <link>shared:<define>THROW_DYN_LINK=1 ;
run dynamic_link_test.cpp throw_test : : : <link>shared : throw_test_shared ;
system-run initialization_test.cpp ;
run header_only_test.cpp : : : -<library>/boost/system//boost_system ;
run header_only_test.cpp : : : -<library>/boost/system//boost_system <define>BOOST_NO_ANSI_APIS : header_only_test_no_ansi ;
system-run header_only_test.cpp ;
run config_test.cpp : : : <test-info>always_show_run_output ;
system-run- std_interop_test.cpp ;
system-run std_interop_test.cpp ;
system-run std_mismatch_test.cpp ;
lib single_instance_lib1 : single_instance_1.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
lib single_instance_lib2 : single_instance_2.cpp : <link>shared:<define>SINGLE_INSTANCE_DYN_LINK ;
system-run single_instance_test.cpp single_instance_1.cpp single_instance_2.cpp ;
run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>static : single_instance_lib_static ;
run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <link>shared : single_instance_lib_shared ;
system-run before_main_test.cpp ;
run-fail throws_assign_fail.cpp ;
system-run- constexpr_test.cpp ;
system-run constexpr_test.cpp ;
system-run win32_hresult_test.cpp ;
system-run error_category_test.cpp ;
@ -128,9 +56,36 @@ system-run generic_category_test.cpp ;
system-run system_category_test.cpp ;
system-run after_main_test.cpp ;
system-run failed_test.cpp ;
system-run- failed_constexpr_test.cpp ;
system-run failed_constexpr_test.cpp ;
# Quick (CI) test
run quick.cpp ;
run quick.cpp : : : <warnings>all <warnings-as-errors>on : warnings_test ;
compile warnings_test.cpp
: <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on ;
lib std_single_instance_lib1 : std_single_instance_1.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>STD_SINGLE_INSTANCE_DYN_LINK ;
system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ;
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ;
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ;
run is_error_code_enum_test.cpp ;
run is_error_condition_enum_test.cpp ;
run errc_test.cpp ;
run errc_test2.cpp ;
run error_category_test2.cpp ;
run error_condition_test.cpp ;
run error_condition_test2.cpp ;
run generic_category_test2.cpp ;
run generic_category_test3.cpp ;
run system_category_test2.cpp ;
run system_category_test3.cpp ;
run windows_error_test.cpp ;
run cygwin_error_test.cpp ;
run linux_error_test.cpp ;

View File

@ -0,0 +1,18 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_system REQUIRED)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::system Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,22 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/system)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../core boostorg/core)
add_subdirectory(../../../predef boostorg/predef)
add_subdirectory(../../../winapi boostorg/winapi)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::system Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,29 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/cygwin_error.hpp>
#include <boost/config/pragma_message.hpp>
#if !defined(__CYGWIN__)
BOOST_PRAGMA_MESSAGE( "Skipping test, __CYGWIN__ is not defined" )
int main() {}
#else
#include <boost/core/lightweight_test.hpp>
int main()
{
namespace sys = boost::system;
sys::error_code ec = sys::cygwin_error::no_package;
BOOST_TEST_EQ( ec, sys::cygwin_error::no_package );
BOOST_TEST_EQ( ec, sys::error_code( ENOPKG, sys::system_category() ) );
return boost::report_errors();
}
#endif

18
test/errc_test.cpp Normal file
View File

@ -0,0 +1,18 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/errc.hpp>
#include <boost/system/is_error_condition_enum.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::success ), 0 );
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::no_such_file_or_directory ), ENOENT );
BOOST_TEST_EQ( static_cast<int>( boost::system::errc::address_family_not_supported ), EAFNOSUPPORT );
BOOST_TEST( boost::system::is_error_condition_enum< boost::system::errc::errc_t >::value );
return boost::report_errors();
}

20
test/errc_test2.cpp Normal file
View File

@ -0,0 +1,20 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/errc.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_TEST_EQ( make_error_code( boost::system::errc::success ).value(), 0 );
BOOST_TEST_EQ( make_error_condition( boost::system::errc::success ).value(), 0 );
BOOST_TEST_EQ( make_error_code( boost::system::errc::no_such_file_or_directory ).value(), ENOENT );
BOOST_TEST_EQ( make_error_condition( boost::system::errc::no_such_file_or_directory ).value(), ENOENT );
BOOST_TEST_EQ( make_error_code( boost::system::errc::address_family_not_supported ).value(), EAFNOSUPPORT );
BOOST_TEST_EQ( make_error_condition( boost::system::errc::address_family_not_supported ).value(), EAFNOSUPPORT );
return boost::report_errors();
}

View File

@ -0,0 +1,79 @@
// Copyright 2018, 2020 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/system
// Avoid spurious VC++ warnings
#define _CRT_SECURE_NO_WARNINGS
#include <boost/system/error_category.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstdio>
//
namespace sys = boost::system;
class user_category: public sys::error_category
{
public:
virtual const char * name() const BOOST_NOEXCEPT
{
return "user";
}
virtual std::string message( int ev ) const
{
char buffer[ 256 ];
std::sprintf( buffer, "user message %d", ev );
return buffer;
}
using sys::error_category::message;
};
static user_category s_cat_1;
static user_category s_cat_2;
int main()
{
// default_error_condition
BOOST_TEST( s_cat_1.default_error_condition( 1 ).value() == 1 );
BOOST_TEST( s_cat_1.default_error_condition( 1 ).category() == s_cat_1 );
BOOST_TEST( s_cat_2.default_error_condition( 2 ).value() == 2 );
BOOST_TEST( s_cat_2.default_error_condition( 2 ).category() == s_cat_2 );
// equivalent
BOOST_TEST( s_cat_1.equivalent( 1, s_cat_1.default_error_condition( 1 ) ) );
BOOST_TEST( !s_cat_1.equivalent( 1, s_cat_1.default_error_condition( 2 ) ) );
BOOST_TEST( !s_cat_1.equivalent( 1, s_cat_2.default_error_condition( 2 ) ) );
// message
{
char buffer[ 256 ];
BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), s_cat_1.message( 1 ).c_str() );
}
{
char buffer[ 4 ];
BOOST_TEST_CSTR_EQ( s_cat_1.message( 1, buffer, sizeof( buffer ) ), "use" );
}
// ==
BOOST_TEST_NOT( s_cat_1 == s_cat_2 );
BOOST_TEST( s_cat_1 != s_cat_2 );
return boost::report_errors();
}

View File

@ -11,11 +11,8 @@
#include <boost/config/warning_disable.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/system/error_code.hpp>
#include <boost/system/cygwin_error.hpp>
#include <boost/system/linux_error.hpp>
#include <boost/system/windows_error.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iostream>
#include <sstream>
#include <string>
@ -197,7 +194,8 @@ int main( int, char ** )
#if defined(BOOST_WINDOWS_API)
// Borland appends newline, so just check text
BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
BOOST_TEST( ec_0_system.message().substr(0,36) == "The operation completed successfully" );
// Fails when the language isn't US English
// BOOST_TEST( ec_0_system.message().substr(0,36) == "The operation completed successfully" );
#elif defined(linux) || defined(__linux) || defined(__linux__)
// Linux appends value to message as unsigned, so it varies with # of bits
BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
@ -293,29 +291,7 @@ int main( int, char ** )
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
# ifdef __CYGWIN__
std::cout << "Cygwin tests...\n";
ec = cygwin_error::no_package;
BOOST_TEST( ec == cygwin_error::no_package );
BOOST_TEST( ec == error_code( ENOPKG, system_category() ) );
BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category() ) );
BOOST_TEST( ec.default_error_condition().category() == system_category() );
# elif defined(linux) || defined(__linux) || defined(__linux__)
std::cout << "Linux tests...\n";
ec = linux_error::dot_dot_error;
BOOST_TEST( ec == linux_error::dot_dot_error );
BOOST_TEST( ec == error_code( EDOTDOT, system_category() ) );
BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category() ) );
BOOST_TEST( ec.default_error_condition().category() == system_category() );
# endif
#endif
return ::boost::report_errors();
}

View File

@ -0,0 +1,31 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_condition.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
sys::error_condition en;
BOOST_TEST_EQ( en.value(), 0 );
BOOST_TEST( !en );
sys::error_condition en2( en );
BOOST_TEST( en == en2 );
BOOST_TEST_NOT( en != en2 );
en2.assign( 1, en.category() );
BOOST_TEST_EQ( en2.value(), 1 );
BOOST_TEST( en2 );
BOOST_TEST_NOT( en == en2 );
BOOST_TEST( en != en2 );
return boost::report_errors();
}

View File

@ -0,0 +1,25 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_condition.hpp>
#include <boost/system/errc.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
sys::error_condition en( sys::errc::no_such_file_or_directory );
BOOST_TEST_EQ( en.value(), ENOENT );
BOOST_TEST( en );
BOOST_TEST( !!en );
BOOST_TEST( en == make_error_condition( sys::errc::no_such_file_or_directory ) );
BOOST_TEST( en.category() == sys::error_condition().category() );
return boost::report_errors();
}

View File

@ -120,18 +120,30 @@ template<class Ec> void test()
ec.assign( 0, generic_category() );
TEST_NOT_FAILED( ec );
}
}
{
Ec ec( 0, http_category() );
TEST_FAILED( ec );
template<class Ec> void test2()
{
Ec ec( 0, http_category() );
TEST_FAILED( ec );
ec.assign( 200, http_category() );
TEST_NOT_FAILED( ec );
ec.assign( 200, http_category() );
TEST_NOT_FAILED( ec );
ec = Ec( 404, http_category() );
TEST_FAILED( ec );
}
ec = Ec( 404, http_category() );
TEST_FAILED( ec );
}
template<class Ec> void test3()
{
Ec ec( 0, http_category() );
BOOST_TEST( ec.failed() );
ec.assign( 200, http_category() );
BOOST_TEST( !ec.failed() );
ec = Ec( 404, http_category() );
BOOST_TEST( ec.failed() );
}
int main()
@ -147,7 +159,9 @@ int main()
BOOST_TEST( http_category().failed( 404 ) );
test<error_code>();
test2<error_code>();
test<error_condition>();
test3<error_condition>();
{
error_condition ec( errc::success );

View File

@ -0,0 +1,20 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/generic_category.hpp>
#include <boost/core/lightweight_test.hpp>
// Tests whether generic_category() is functional when only
// generic_category.hpp is included
namespace sys = boost::system;
int main()
{
sys::error_category const & cat = sys::generic_category();
BOOST_TEST_CSTR_EQ( cat.name(), "generic" );
return boost::report_errors();
}

View File

@ -0,0 +1,30 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/generic_category.hpp>
#include <boost/system/error_condition.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
namespace sys = boost::system;
int main()
{
sys::error_category const & cat = sys::generic_category();
// name
BOOST_TEST_CSTR_EQ( cat.name(), "generic" );
// default_error_condition
BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition( 0, cat ) );
BOOST_TEST( cat.default_error_condition( ENOENT ) == sys::error_condition( ENOENT, cat ) );
BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
// failed
BOOST_TEST( !cat.failed( 0 ) );
BOOST_TEST( cat.failed( ENOENT ) );
BOOST_TEST( cat.failed( -1 ) );
return boost::report_errors();
}

View File

@ -0,0 +1,41 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/is_error_code_enum.hpp>
#include <boost/core/lightweight_test.hpp>
enum error
{
success = 0,
e1,
e2,
e3
};
namespace boost
{
namespace system
{
template<> struct is_error_code_enum< ::error >
{
static const bool value = true;
};
}
}
boost::system::error_code make_error_code( ::error e );
enum not_error
{
};
int main()
{
BOOST_TEST( boost::system::is_error_code_enum< ::error >::value );
BOOST_TEST( !boost::system::is_error_code_enum< ::not_error >::value );
return boost::report_errors();
}

View File

@ -0,0 +1,40 @@
// Copyright 2020 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/is_error_condition_enum.hpp>
#include <boost/core/lightweight_test.hpp>
enum condition
{
c1 = 1,
c2,
c3
};
namespace boost
{
namespace system
{
template<> struct is_error_condition_enum< ::condition >
{
static const bool value = true;
};
}
}
boost::system::error_condition make_error_condition( ::condition e );
enum not_condition
{
};
int main()
{
BOOST_TEST( boost::system::is_error_condition_enum< ::condition >::value );
BOOST_TEST( !boost::system::is_error_condition_enum< ::not_condition >::value );
return boost::report_errors();
}

29
test/linux_error_test.cpp Normal file
View File

@ -0,0 +1,29 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/linux_error.hpp>
#include <boost/config/pragma_message.hpp>
#if !defined(__linux__)
BOOST_PRAGMA_MESSAGE( "Skipping test, __linux__ is not defined" )
int main() {}
#else
#include <boost/core/lightweight_test.hpp>
int main()
{
namespace sys = boost::system;
sys::error_code ec = sys::linux_error::dot_dot_error;
BOOST_TEST_EQ( ec, sys::linux_error::dot_dot_error );
BOOST_TEST_EQ( ec, sys::error_code( EDOTDOT, sys::system_category() ) );
return boost::report_errors();
}
#endif

View File

@ -8,6 +8,7 @@
// See library home page at http://www.boost.org/libs/system
#include <boost/system/system_error.hpp>
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
@ -32,5 +33,10 @@ int main()
BOOST_TEST( bc == bn );
boost::system::system_error x( bc, "prefix" );
BOOST_TEST_EQ( x.code(), bc );
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
return boost::report_errors();
}

View File

@ -0,0 +1,40 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(STD_SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <system_error>
namespace lib1
{
EXPORT std::error_code get_system_code()
{
return boost::system::error_code( 0, boost::system::system_category() );
}
EXPORT std::error_code get_generic_code()
{
return boost::system::error_code( 0, boost::system::generic_category() );
}
} // namespace lib1
#else
EXPORT void lib1_f()
{
}
#endif

View File

@ -0,0 +1,40 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#if defined(STD_SINGLE_INSTANCE_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
#else
# define EXPORT
#endif
#include <boost/system/error_code.hpp>
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
#include <system_error>
namespace lib2
{
EXPORT std::error_code get_system_code()
{
return boost::system::error_code( 0, boost::system::system_category() );
}
EXPORT std::error_code get_generic_code()
{
return boost::system::error_code( 0, boost::system::generic_category() );
}
} // namespace lib2
#else
EXPORT void lib2_f()
{
}
#endif

View File

@ -0,0 +1,76 @@
// Copyright 2019 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
#include <boost/system/error_code.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config/helper_macros.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(STD_SINGLE_INSTANCE_SHARED) && defined(__CYGWIN__)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, __CYGWIN__" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_MSC_VER)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _MSC_VER" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && !defined(_CPPLIB_VER)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, no _CPPLIB_VER" )
int main() {}
#elif defined(STD_SINGLE_INSTANCE_SHARED) && defined(_WIN32) && (_MSC_VER < 1900 || _MSC_VER >= 2000)
BOOST_PRAGMA_MESSAGE( "Skipping Windows/DLL test, _MSC_VER is " BOOST_STRINGIZE(_MSC_VER) )
int main() {}
#else
#include <boost/core/lightweight_test.hpp>
#include <system_error>
using namespace boost::system;
namespace lib1
{
std::error_code get_system_code();
std::error_code get_generic_code();
} // namespace lib1
namespace lib2
{
std::error_code get_system_code();
std::error_code get_generic_code();
} // namespace lib2
int main()
{
{
std::error_code e1 = lib1::get_system_code();
std::error_code e2 = lib2::get_system_code();
BOOST_TEST_EQ( e1, e2 );
}
{
std::error_code e1 = lib1::get_generic_code();
std::error_code e2 = lib2::get_generic_code();
BOOST_TEST_EQ( e1, e2 );
}
return boost::report_errors();
}
#endif

View File

@ -18,6 +18,16 @@
//
#if defined(BOOST_WINDOWS_API) && defined(BOOST_SYSTEM_USE_UTF8)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test due to BOOST_WINDOWS_API && BOOST_SYSTEM_USE_UTF8" )
int main() {}
#else
#if defined(BOOST_WINDOWS_API)
#include <windows.h>
@ -90,7 +100,7 @@ static void test_message( sys::error_category const & cat, int ev )
{
BOOST_TEST_EQ( cat.message( ev ), sys_strerror( ev ) );
char buffer[ 2048 ]; // yes, really
char buffer[ 4096 ]; // yes, really
BOOST_TEST_CSTR_EQ( cat.message( ev, buffer, sizeof( buffer ) ), sys_strerror( ev ).c_str() );
}
@ -100,17 +110,12 @@ int main()
// message
for( int i = -2; i < 1024; ++i )
{
test_message( cat, i );
}
test_message( cat, 5810 );
for( int i = 10000; i < 11032; ++i )
for( int i = -2; i < 16000; ++i )
{
test_message( cat, i );
}
return boost::report_errors();
}
#endif // #if defined(BOOST_WINDOWS_API) && defined(BOOST_SYSTEM_USE_UTF8)

View File

@ -0,0 +1,20 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/system_category.hpp>
#include <boost/core/lightweight_test.hpp>
// Tests whether system_category() is functional when only
// system_category.hpp is included
namespace sys = boost::system;
int main()
{
sys::error_category const & cat = sys::system_category();
BOOST_TEST_CSTR_EQ( cat.name(), "system" );
return boost::report_errors();
}

View File

@ -0,0 +1,39 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/system_category.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/system/error_condition.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
sys::error_category const & cat = sys::system_category();
// name
BOOST_TEST_CSTR_EQ( cat.name(), "system" );
// default_error_condition
BOOST_TEST( cat.default_error_condition( 0 ) == sys::error_condition() );
BOOST_TEST( cat.default_error_condition( -1 ) == sys::error_condition( -1, cat ) );
#if defined(BOOST_WINDOWS_API)
BOOST_TEST( cat.default_error_condition( 5 ) == sys::error_condition( EACCES, sys::generic_category() ) );
#else
BOOST_TEST( cat.default_error_condition( EACCES ) == sys::error_condition( EACCES, sys::generic_category() ) );
#endif
// failed
BOOST_TEST( !cat.failed( 0 ) );
BOOST_TEST( cat.failed( 5 ) );
BOOST_TEST( cat.failed( -1 ) );
return boost::report_errors();
}

View File

@ -37,7 +37,7 @@ namespace
BOOST_TEST( ex.code().category() == system_category() );
# ifdef BOOST_WINDOWS_API
LANGID language_id;
# if !defined(__MINGW32__) && !defined(__CYGWIN__) && !BOOST_PLAT_WINDOWS_RUNTIME
# if !BOOST_PLAT_WINDOWS_RUNTIME
language_id = ::GetUserDefaultUILanguage();
# else
language_id = 0x0409; // Assume US English

52
test/warnings_test.cpp Normal file
View File

@ -0,0 +1,52 @@
// Copyright 2017, 2019 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/system
#if defined(__GNUC__) && __GNUC__ >= 5 && __cplusplus >= 201103L
# pragma GCC diagnostic error "-Wsuggest-override"
#endif
#include <boost/config.hpp>
#if defined( BOOST_GCC ) && BOOST_GCC < 40600
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
#include <boost/system/system_error.hpp>
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
int main()
{
boost::system::error_category const & bt = boost::system::generic_category();
int ev = ENOENT;
boost::system::error_code bc( ev, bt );
BOOST_TEST_EQ( bc.value(), ev );
BOOST_TEST_EQ( &bc.category(), &bt );
boost::system::error_condition bn = bt.default_error_condition( ev );
BOOST_TEST_EQ( bn.value(), ev );
BOOST_TEST_EQ( &bn.category(), &bt );
BOOST_TEST( bt.equivalent( ev, bn ) );
BOOST_TEST( bc == bn );
boost::system::system_error x( bc, "prefix" );
BOOST_TEST_EQ( x.code(), bc );
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
return boost::report_errors();
}

View File

@ -0,0 +1,31 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/windows_error.hpp>
#include <boost/config/pragma_message.hpp>
#if !defined(BOOST_WINDOWS_API)
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_WINDOWS_API is not defined" )
int main() {}
#else
#include <boost/core/lightweight_test.hpp>
#include <windows.h>
int main()
{
namespace sys = boost::system;
sys::error_code ec = sys::windows_error::invalid_function;
BOOST_TEST_EQ( ec, sys::windows_error::invalid_function );
BOOST_TEST_EQ( ec, sys::error_code( ERROR_INVALID_FUNCTION, sys::system_category() ) );
BOOST_TEST( ec == make_error_condition( sys::errc::function_not_supported ) );
return boost::report_errors();
}
#endif