Compare commits

...

531 Commits

Author SHA1 Message Date
7a49a5d80d Change assertions in operator* to match documentation; improves codegen slightly in the result<U&> case 2025-02-24 19:46:43 +02:00
a0597f4872 Update .drone.jsonnet 2024-12-14 11:02:33 +02:00
485be93281 Apply Node20 workaround 2024-12-14 11:01:15 +02:00
ee0b15efc4 Update ci.yml 2024-12-14 11:00:28 +02:00
09f4eb87e2 Merge pull request #125 from igaztanaga/patch-1
Update system_category_message_win32.hpp
2024-09-05 21:25:41 +03:00
3e5ce27719 Add VERBATIM to add_custom_target 2024-08-28 03:02:08 +03:00
40bdcea2e5 Update build.jam, build/Jamfile, test/Jamfile 2024-08-28 02:10:03 +03:00
19bcfebf37 Sync from upstream. 2024-08-20 09:56:38 -05:00
6d58d0bb76 Update system_category_message_win32.hpp
Fixes for Wsign-conversion with MinGW64 ("conversion to 'DWORD' {aka 'long unsigned int'} from 'int' may change the sign of the result")
2024-08-19 01:10:16 +02:00
a664cd1de6 Update .drone.jsonnet 2024-08-18 11:46:25 +03:00
e8a089b664 Update ci.yml 2024-08-17 18:22:21 +03:00
75e1a1e28b Update build deps. 2024-08-09 20:26:47 -05:00
5feb280612 Move inter-lib dependencies to a project variable and into the build targets. 2024-07-23 22:34:22 -05:00
fc3ab6db97 Update copyright dates. 2024-07-20 22:52:03 -05:00
91929719bd Change all <source> references to <library>. 2024-07-20 21:26:25 -05:00
8d0fa396b8 Bump B2 require to 5.2 2024-06-14 11:33:56 -05:00
671d0ad41b Sync from upstream. 2024-06-02 23:25:04 -05:00
5d5ecb74a7 Update .drone.jsonnet 2024-06-03 03:01:59 +03:00
41ff095c0a Try to fix the false positive with GCC ASAN 2024-06-03 02:40:13 +03:00
38d63aaf7c strerror_r(ev, tmp, 0) may return tmp 2024-06-02 23:03:24 +03:00
d1fb7554c5 Update error_code_test2, error_condition_test3 2024-06-02 22:41:48 +03:00
c63bca6eda Update error_condition_test3.cpp 2024-06-02 22:33:43 +03:00
bef2c5ef6a Update error_code_test2.cpp 2024-06-02 22:26:01 +03:00
341f960e72 Sync from upstream. 2024-06-02 13:49:02 -05:00
4d4f906548 strerror_r requires non-null buffer pointer
Fixes -Wnonnull warnings when calling message with a nullptr buffer
2024-06-02 18:21:07 +00:00
8a92683012 Add tests for calling message with nullptr buffer 2024-06-02 18:20:16 +00:00
be5a8ffa80 Disable -Wformat-truncation for Clang in snprintf_test 2024-06-02 19:45:18 +03:00
d032ab91fd Update ci.yml 2024-06-02 18:59:05 +03:00
9b82082f76 Add requires-b2 check to top-level build file. 2024-05-05 09:00:01 -05:00
3c293f8740 Add missing NO_LIB usage requirements. 2024-04-28 20:17:00 -05:00
2feb94ac07 Sync from upstream. 2024-04-20 15:31:42 -05:00
8f319f30c6 Update revision history 2024-04-17 03:41:33 +03:00
d09b2f5f1d Sync from upstream. 2024-04-10 07:55:53 -05:00
01d46f597e Update test/result_and_fn1v.cpp 2024-04-09 03:07:07 +03:00
93852d1a7e Support result<void> &= fv. Refs #119. 2024-04-09 03:01:38 +03:00
4aeebd2173 Avoid Appveyor timeout 2024-04-08 21:47:32 +03:00
96fef94580 Support result<void> & fv, where fv returns void. Refs #119. 2024-04-08 18:01:41 +03:00
75ab18c9fd Support result<X> & fv, where fv returns void. Refs #119. 2024-04-08 17:55:50 +03:00
f9a4655ae7 Merge pull request #120 from klemens-morgenstern/patch-1
declared global constants as inline with BOOST_INLINE_CONSTEXPR
2024-04-06 21:48:49 +03:00
f6fcb1b690 declared global constants as inline with BOOST_INLINE_CONSTEXPR 2024-04-06 21:54:33 +08:00
27a5096b6c Switch to library requirements instead of source. As source puts extra source in install targets. 2024-03-29 21:15:59 -05:00
9cc66841c4 Make the library modular usable. 2024-03-11 08:38:16 -05:00
2fc720a1cb Update documentation 2024-02-03 04:07:53 +02:00
73de83b8f7 Update documentation 2024-02-02 08:28:41 +02:00
310bf1d544 Add operator|=(result&, fn0r) 2024-02-01 07:18:41 +02:00
f18edb3d24 Add operator|=(result&, fn0v) 2024-02-01 06:49:23 +02:00
a9659f4318 Add operator|=(result&, value) 2024-02-01 06:40:47 +02:00
2b14b9a96a Update documentation 2024-02-01 03:24:33 +02:00
c7a0ce3349 Enable result<void> &= fr. Refs #117. 2024-02-01 02:39:31 +02:00
cedf6eb581 Update test/result_and_fn1r.cpp 2024-02-01 02:22:05 +02:00
ab368822a6 Update documentation 2024-01-31 11:35:41 +02:00
293174a1d3 Enable result<void> & fr. Refs #117. 2024-01-31 05:36:52 +02:00
5c1d0df893 Enable result<void> & fv. Refs #117. 2024-01-31 05:26:01 +02:00
3f2f87f734 Update ci.yml 2024-01-26 01:35:05 +02:00
6caa346ba5 Update documentation 2024-01-25 22:13:49 +02:00
a5aec941ca Remove boost/system/cygwin_error.hpp 2024-01-18 20:21:45 +02:00
7f640b92fe Update appveyor.yml 2024-01-18 19:42:44 +02:00
626263c23f Update CMakeLists.txt 2024-01-17 07:45:05 +02:00
53ce7e9f53 Update meta/libraries.json 2024-01-17 07:18:04 +02:00
ff47c6782f Include and test unconditionally result.hpp 2024-01-17 07:17:30 +02:00
abbfd46517 Remove uses of BOOST_NOEXCEPT 2024-01-17 07:14:05 +02:00
128fd9341f Remove uses of BOOST_CONSTEXPR 2024-01-17 07:09:31 +02:00
e0b0118406 Remove msvc-12.0 from Appveyor 2024-01-17 07:07:25 +02:00
3ded81eed0 Remove uses of BOOST_SYSTEM_HAS_SYSTEM_ERROR 2024-01-17 06:49:19 +02:00
80e019069c Use snprintf in error_category_impl.hpp 2024-01-17 05:18:23 +02:00
e368c2863d Disable -Wformat-truncation in snprintf_test.cpp 2024-01-17 05:13:10 +02:00
00fb79f174 Remove requires_cxx11.hpp 2024-01-17 04:47:46 +02:00
44582f3c3c Use std::snprintf in detail/snprintf.hpp 2024-01-17 04:34:11 +02:00
f08e363c0e Use std::is_same in detail/is_same.hpp 2024-01-17 04:33:14 +02:00
1474498ccf Use std::enable_if in detail/enable_if.hpp 2024-01-17 04:32:29 +02:00
b0304ad0b2 Remove msvc-9.0, 10.0, 11.0 from Appveyor 2024-01-17 04:31:25 +02:00
9974d92675 Remove GCC 4.4, 4.6, 4.7 from Drone 2024-01-17 04:30:55 +02:00
945b0591dd Unconditionally enable BOOST_SYSTEM_HAS_SYSTEM_ERROR 2024-01-17 04:14:23 +02:00
1f1e4e0400 Remove NO_CXX11 macros from config_test.cpp 2024-01-17 04:12:51 +02:00
1a0b9a46a8 Remove static_assert workaround 2024-01-17 04:12:13 +02:00
f132dca4a9 Remove =default/=delete workarounds 2024-01-17 04:11:19 +02:00
81a9952695 Remove BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS workarounds 2024-01-17 03:57:53 +02:00
b877f65f80 Remove C++03 from appveyor.yml 2024-01-17 03:54:47 +02:00
aa80e0bdcd Remove C++03 from .drone.jsonnet 2024-01-17 03:53:54 +02:00
0b60b13618 Remove C++03 from ci.yml 2024-01-17 03:51:39 +02:00
7dacf5be11 Update .drone.jsonnet 2024-01-01 19:42:54 +02:00
c3cd1d5ea9 Disable failed_constexpr_test for GCC/UBSAN 2023-12-31 02:25:26 +02:00
2bea482605 Update .drone.jsonnet 2023-12-31 01:26:31 +02:00
48f95f0035 Update .drone.jsonnet 2023-12-31 01:11:31 +02:00
16d20175bc Update .drone.jsonnet 2023-12-28 16:18:53 +02:00
2aa5d4d97f Add definitions of ::in_place_* for result specializations. Fixes #115. 2023-12-15 03:17:21 +02:00
18edbf75d0 Test ::in_place_* for result specializations. Refs #115. 2023-12-15 02:44:14 +02:00
52220a0351 Add definitions of result<T, E>::in_place_*. Refs #115. 2023-12-15 02:24:18 +02:00
ffa67ab005 Add test for ODR-use of ::in_place_* (refs #115) 2023-12-15 02:11:19 +02:00
d8399efcac Update ci.yml 2023-12-15 01:42:22 +02:00
8bc32b7267 Update documentation 2023-10-31 04:20:33 +02:00
d11dd4b396 Add operator&=( result&, unary-returning-result ) 2023-10-31 03:08:02 +02:00
ca5bca39ce Add operator&=( result&, unary-returning-value ) 2023-10-31 02:44:45 +02:00
a58115cb50 Reorder operator& code for better codegen 2023-10-31 01:51:38 +02:00
1bc08296de Update documentation 2023-10-30 21:03:39 +02:00
25479216b3 Fix test file names 2023-10-30 00:52:38 +02:00
54d3b253b1 Add operator&( result, unary-returning-result ) 2023-10-29 20:57:29 +02:00
194b84e663 Add operator&( result, unary-returning-value ) 2023-10-29 19:37:43 +02:00
47a08cb35b Update documentation 2023-10-29 19:14:13 +02:00
7ffd63d54c Fix rvalue result<void> cases 2023-10-29 19:13:11 +02:00
92c24da9a1 Document operator| 2023-10-29 03:10:27 +02:00
dc73ca428b Add operator|( result, nullary-returning-result ) 2023-10-29 03:20:08 +03:00
c1fa3619b6 Add operator|( result, nullary-returning-value ) 2023-10-29 02:32:19 +03:00
0cd351014b Remove C++14-ism 2023-10-29 01:41:50 +03:00
d38e54d4c3 Add operator|( result, value ) 2023-10-29 01:30:01 +03:00
fa3331412d Update ci.yml 2023-10-28 20:53:44 +03:00
b899c49ae8 Update .drone.jsonnet 2023-10-21 04:17:30 +03:00
61a0e244da Add some more test cases exercising result initialization from {} 2023-10-20 21:49:20 +03:00
eb788615de Update ci.yml 2023-10-20 03:04:29 +03:00
84fd43e14a Update C++03 deprecation message 2023-10-19 18:15:05 +03:00
b0ef682e3d Update documentation 2023-09-14 02:20:46 +03:00
c360ff1b1c Add a converting constructor to result<void> 2023-09-12 04:48:45 +03:00
951b3fe7b4 Add result<U&, E> specialization. Fixes #72. 2023-09-12 03:34:24 +03:00
a57c568324 Do not use <shared_mutex> when BOOST_USE_WINAPI_VERSION is 0x5xx (Windows XP). Fixes #113. 2023-09-04 16:28:34 +03:00
4843453528 Update ci.yml 2023-09-04 13:04:34 +03:00
2e7e46a802 Update C++03 deprecation message 2023-06-03 02:31:27 +03:00
32dbf1b992 Disable use of <shared_mutex> under the XP toolsets (v140_xp and v141_xp). Fixes #110. 2023-04-30 18:44:56 +03:00
707b24bfa1 Update reference 2023-03-18 05:30:43 +02:00
bb1caae0d5 Update test/result_error_move.cpp 2023-03-18 05:25:44 +02:00
c5c49894e6 Made result::error movable.
Closes #108.
2023-03-17 12:53:14 +08:00
ee80491cab Add C++03 deprecation notice 2023-03-06 07:49:33 +02:00
a83319fde1 Update ci.yml 2023-03-06 06:22:31 +02:00
4b90524729 Disable the constexpr constructors on GCC 4.7 2023-03-01 05:18:23 +02:00
6ac5f23999 Make error_category constructors unconditionally constexpr 2023-03-01 03:36:07 +02:00
f332a52597 Disable C4800 under msvc-14.0 2023-01-22 04:54:46 +02:00
c92d50abbd Do not consider types with explicit operator bool (such as result itself) constructible from bool for the purposes of result construction. Refs #104. 2023-01-22 02:07:28 +02:00
805b260a7a Add test/result_value_construct5.cpp. Refs #104. 2023-01-22 01:58:29 +02:00
f32ffcba48 Update result_value_construct4.cpp 2023-01-22 01:25:30 +02:00
8ce2a9f835 Disable result converting constructor when T is convertible from the rhs result<T2, E2>. Refs #104. 2023-01-22 01:22:02 +02:00
6a58b03eab Add test/result_value_construct4.cpp. Refs #104. 2023-01-22 01:15:08 +02:00
f0b27c5826 Enable implicit construction when the alternative is explicitly constructible from the argument. Fixes #103. 2023-01-21 20:09:53 +02:00
456b3c2dad Add test/result_error_construct4.cpp. Refs #103. 2023-01-21 19:45:32 +02:00
eb3f3a8e41 Use boost::core::snprintf in std_interop_test16 as well 2023-01-20 04:39:08 +02:00
e6986a51d5 Merge branch 'develop' into feature/issue-102 2023-01-20 04:38:15 +02:00
fb648760b5 Change uses of std::sprintf in tests to boost::core::snprintf, to avoid deprecation warnings 2023-01-20 02:29:38 +02:00
71ee26c188 Move the stdcat mutex into init_stdcat() as a local static to fix msvc-12.0 2023-01-20 01:22:42 +02:00
8449c62162 Update detail/mutex.hpp to use std::shared_mutex under the MS STL 2023-01-19 18:05:21 +02:00
4bca94ffc4 Merge branch 'develop' into feature/issue-102 2023-01-19 16:35:05 +02:00
3e6af15652 Add system/detail/mutex.hpp, use it in error_category_impl.hpp 2023-01-19 12:04:06 +02:00
86ff47ff63 Update std_interop_test16.cpp to not use asio/error.hpp. 2023-01-19 11:13:40 +02:00
06ddfdb4a6 Add std_interop_test16.cpp. Refs #102. 2023-01-19 05:46:11 +02:00
bb60a27b18 Update appveyor.yml 2023-01-12 20:38:54 +02:00
e478ba1a2b Update appveyor.yml 2023-01-12 15:18:11 +02:00
50100b0e81 Update CMakeLists.txt 2023-01-12 10:37:55 +02:00
bb502f5d67 Merge branch 'develop' into feature/pr-90 2023-01-12 10:36:56 +02:00
fa2349eee7 Add CMake tests to Appveyor 2023-01-12 05:45:30 +02:00
3d9acaf082 Update CMakeLists.txt 2023-01-12 05:41:30 +02:00
c6795eb9d0 Merge branch 'natvis' of https://github.com/vinniefalco/boost-system into feature/pr-90 2023-01-12 05:39:37 +02:00
57c295bbf7 Work around Clang 3.5 failures in result_value_access 2023-01-10 05:46:57 +02:00
36e3b2c6ae Work around Clang 3.5..3.8 failure in constexpr_test2 2023-01-10 05:14:36 +02:00
583cd8dba2 Update .drone.jsonnet 2023-01-10 04:36:37 +02:00
0c2de4cb2a Update .drone.jsonnet 2023-01-10 04:19:25 +02:00
3d595a6e79 Update ci.yml 2023-01-10 04:06:30 +02:00
b3faedfe3e Extend Clang 6 workaround to Clang 7 under Android. Fixes #100. 2023-01-10 03:09:20 +02:00
32bf67f748 error_code wrapping std::error_code should never compare equal to error_code not wrapping std (because of hash_value.) Fixes #101. 2023-01-07 19:56:34 +02:00
5d15aa1267 Add ec_hash_value_test 2023-01-07 19:42:59 +02:00
36e1236a0f Remove _Addr assignment from the constructor of std_category. Fixes #98. 2022-12-10 22:17:51 +02:00
2c20b6e7e5 Work around ERROR_INVALID_NAME failure on msvc-14.0, msvc-14.1 2022-12-10 19:45:14 +02:00
103f3b4f00 Print original error code in win32_generic_test 2022-12-10 18:47:54 +02:00
14f779e234 Update Win32 translation table. Closes #97. 2022-12-10 18:38:19 +02:00
bfccd4b4d9 Add win32_generic_test. Refs #97. 2022-12-10 18:24:34 +02:00
7ae6b317f3 Only disable C4351 on msvc-12.0 and earlier (refs #96) 2022-10-26 15:52:18 +03:00
9a6d79b841 Update revision history 2022-10-18 04:17:17 +03:00
ece71199a9 Document result<>::emplace 2022-10-18 04:15:40 +03:00
1e4c050d6c Add result<>::emplace (refs #85) 2022-10-18 00:46:59 +03:00
21115121bb Update ci.yml 2022-10-15 04:17:12 +03:00
956fa92a53 Update revision history 2022-09-27 20:32:03 +03:00
ee318f937f Document result<>::value_type, error_type, in_place_value, in_place_error. Closes #93. 2022-09-27 20:23:28 +03:00
19f99264de Document BOOST_SYSTEM_DISABLE_THREADS 2022-09-27 20:20:36 +03:00
3261bae6de Update .drone.jsonnet 2022-09-27 18:58:14 +03:00
20ce51858b Add in_place_value, in_place_error to result<>. Refs #93. 2022-09-27 18:18:16 +03:00
52d7429473 Add value_type, error_type typedefs to result. Refs #93. 2022-09-26 21:20:40 +03:00
53c00841fc Add support for BOOST_SYSTEM_DISABLE_THREADS (refs #92) 2022-09-08 18:32:26 +03:00
19e27a73e9 Disable failing test for msvc-12.0 2022-08-25 17:38:59 +03:00
19020ce925 Disable std_interop_test15 on g++ 4.8/4.9 2022-08-24 23:37:03 +03:00
3faf415026 Resolve ambiguities when comparing error_condition with std enums (refs #91) 2022-08-24 22:56:15 +03:00
a2df4d09da Update error_code_test3.cpp 2022-08-24 21:41:38 +03:00
455c6a6332 Add std_interop_test15.cpp 2022-08-24 21:40:20 +03:00
efb7634666 Move code/condition comparisons back outside class error_code; fixes #91 2022-08-24 21:10:05 +03:00
2bba3fd5e2 Add error_code_test3.cpp 2022-08-24 20:54:20 +03:00
8c740705e6 Add missing include 2022-08-21 19:42:10 +03:00
4708d95e80 Merge branch 'constexpr-default-ctor' of https://github.com/vinniefalco/boost-system into feature/pr-89 2022-08-21 19:13:48 +03:00
867f6d06d0 Add constexpr_test2.cpp 2022-08-21 19:13:12 +03:00
ac1ed1ecc1 error_code default ctor is constexpr in c++11 2022-08-21 08:17:54 -07:00
fe48c3058d add boost_system.natvis and interface source files 2022-08-19 11:40:36 -07:00
cc7c2f7ee4 Return v_.index() == 1 from has_error() to avoid -Wmaybe-uninitialized in error() 2022-08-02 22:44:34 +03:00
f2e1db8021 Constrain explicit value and error constructors to not accept zero arguments. Fixes #86. 2022-07-26 21:49:13 +03:00
ede243c42f Add (negative) tests for default constructability (refs #86) 2022-07-26 21:35:33 +03:00
1558aaa789 Update ci.yml 2022-07-26 20:41:24 +03:00
96b876d91a Add README.md 2022-06-19 02:19:58 +03:00
eb9ae4ac69 Update revision history 2022-06-19 01:30:17 +03:00
8fd487d496 Update documentation 2022-06-19 01:28:36 +03:00
5223c94aa9 Disable throws_assign_fail.cpp for GCC/release, because gcc-12 fails it at compile time 2022-06-18 23:07:41 +03:00
a5ee3f291c Update ci.yml 2022-06-18 21:47:57 +03:00
4200b00973 Add converting constructor to result (refs #82) 2022-06-18 18:12:06 +03:00
533dfe1688 Update revision history 2022-05-05 21:17:09 +03:00
7dec756a6f Update documentation 2022-05-05 21:15:03 +03:00
648a35838b Remove unnecessary overloads 2022-05-05 05:12:08 +03:00
256fe92dbb Add error_code(error_code const& ec, source_location const* loc) and a corresponding assign 2022-05-05 05:02:37 +03:00
5debb8a041 Update revision history 2022-05-05 02:30:07 +03:00
a97e5a0546 Move BOOST_NOINLINE to operator std::error_category 2022-04-22 22:41:26 +03:00
dc17edfa07 Remove clang-win from appveyor.yml 2022-04-22 21:16:09 +03:00
65da7dfd56 Update result_error_construct tests to use sys::error_code instead of (erroneously) std::error_code 2022-04-22 19:52:19 +03:00
9279001b8c Check BOOST_NO_CXX11_HDR_MUTEX when enabling <system_error> integration 2022-04-22 16:49:03 +03:00
616e652bd7 Suppress strict-aliasing warning for gcc 4.8 to 6 2022-04-21 21:06:14 +03:00
98439855bd Use static_cast instead of reinterpret_cast 2022-04-21 20:52:02 +03:00
986efb1420 Rework conversion to std::error_category to not allocate (closes #78) 2022-04-21 20:32:25 +03:00
28a13571b9 Restore the original system::error_code from std::error_code (refs #79) 2022-03-18 18:24:01 +02:00
65ed1eef66 Add std_interop_test14.cpp (refs #79) 2022-03-18 08:12:05 +02:00
6de20eeebc Add std_interop_test13 2022-03-18 08:12:05 +02:00
0a9266ea7e Add a comment explaining the one-time allocation in error_category_impl.hpp. Fixes #78. 2022-03-18 08:11:16 +02:00
adb9fc54cb Remove msvc-14.1 from ci.yml 2022-03-18 07:51:38 +02:00
e197c5e803 Update documentation 2022-02-18 19:43:08 +02:00
6d7a57a970 Add throw_exception_from_error overload for std::exception_ptr 2022-02-18 02:55:34 +02:00
00c71cf388 Add throw_exception_from_error overloads for boost::system::errc, std::errc 2022-02-17 21:55:47 +02:00
d930cea481 Update documentation 2022-02-14 02:05:44 +02:00
4f09f4adde Use throw_with_location in throw_exception_from_error 2022-02-13 22:50:20 +02:00
abd62362ef Update documentation 2022-02-09 20:52:23 +02:00
8d8e6a90de Add an errc::make_error_code overload taking a source location 2022-02-09 20:41:34 +02:00
716c2ed8ef Disable result tests on GCC 4.7 2022-02-07 21:40:26 +02:00
46a5ecd490 Do not include boost/system/result.hpp on GCC 4.7 2022-02-07 21:38:14 +02:00
79f4ef0416 Remove .drone.star 2022-02-07 21:34:11 +02:00
d0a8f7fbb7 Squash-merge feature/drone-jsonnet into develop 2022-02-07 21:33:48 +02:00
bc07ab1e25 Update .drone.star 2022-02-07 05:09:49 +02:00
c6bff94709 Update std_interop_test12.cpp 2022-02-07 04:35:44 +02:00
ae079810be Add std_interop_test12.cpp 2022-02-07 04:30:50 +02:00
928de55563 Update .drone.star 2022-02-07 03:47:42 +02:00
442138de0a Update .drone.star 2022-02-07 03:41:35 +02:00
de610efd53 Move conditions to detail/config.hpp 2022-02-07 03:16:23 +02:00
4b143cdacc Use BOOST_LIBSTDCXX_VERSION instead of BOOST_GCC; update syscat condition 2022-02-07 03:02:57 +02:00
a1cb578f52 Update .drone.star 2022-02-07 02:55:54 +02:00
96b5073b79 Update .drone.star 2022-02-07 02:03:13 +02:00
2bff5c7071 Update .drone.star 2022-02-07 01:27:59 +02:00
137128176d Update .drone.star 2022-02-07 01:14:28 +02:00
e0e0f56eae Update .drone.star 2022-02-07 00:54:07 +02:00
58d55a67e5 Update .drone.star 2022-02-07 00:01:53 +02:00
34dcb59ee8 Update drone.bat 2022-02-06 23:30:19 +02:00
33f6ecba31 Update Drone files 2022-02-06 23:21:40 +02:00
23fbfb1ffa Update .drone.star 2022-02-06 22:55:48 +02:00
5366407135 Add Windows jobs to Drone 2022-02-06 22:42:19 +02:00
72a79b1dcb Disable -Wsign-compare for GCC 4.4 2022-02-06 22:29:28 +02:00
a5c1ab042e Update Drone files 2022-02-06 22:25:45 +02:00
c2beb75d66 Merge pull request #59 from sdarwin/drone
Drone config
2022-02-06 22:08:07 +02:00
54d9f4f38a Update documentation 2022-02-05 19:25:43 +02:00
b92be6417a Add a source_location parameter to throw_exception_from_error 2022-02-05 05:24:29 +02:00
245fff8af3 Update ci.yml 2022-02-05 03:11:09 +02:00
c359af3141 Update system_error constructors 2022-02-04 21:34:14 +02:00
50cad72fac Update system_error_test3.cpp 2022-02-04 21:22:35 +02:00
9554d8bbd3 Suppress incorrect warnings from GCC 7/8 2022-02-03 19:02:19 +02:00
cf9d986871 Update documentation 2022-02-03 18:47:53 +02:00
a5d68e52e6 Add throw_exception_from_error overload for std::error_code 2022-02-03 18:35:42 +02:00
9c6a09f41d Mark throw_exception_from_error as noinline 2022-02-03 09:37:59 +02:00
b9c26b9fa0 Add detail::system_error_category_message, use it in error_code::message 2022-02-03 05:47:43 +02:00
2e2430c4fa Add error_code::category_name helper, use it in to_string 2022-02-03 04:36:58 +02:00
4b1caad727 Avoid sign conversion warnings in error_code::value 2022-01-19 17:30:56 +02:00
5b96abbaa8 Undeprecate linux_error.hpp (closes #77) 2021-12-27 02:53:04 +02:00
2e1c800d82 Update appveyor.yml 2021-12-21 22:35:10 +02:00
04a79d710f Merge branch 'fix_error_code_wostream' of https://github.com/MarcelRaad/system into feature/pr-76 2021-12-21 19:51:50 +02:00
5700936367 Add ec_wstream_test (refs #76) 2021-12-21 19:51:08 +02:00
86b031cab9 Fix error_code's operator<< for arbitrary basic_ostream specializations
This fixes a regression from commit
a9b64a888a.
Calling `operator<<` with `std::string` only works for `std::ostream`.
Use `c_str()` to restore the previous behavior of using `const char*`,
which works for any `basic_ostream` specialization.
2021-12-21 13:17:26 +01:00
204e65f725 Add msvc-14.0 to GHA 2021-12-11 03:42:52 +02:00
01ce081470 Disable errc_t -> arithmetic conversions when initializing result (closes #74) 2021-12-11 01:22:08 +02:00
8c9ceba775 Add negative test for constructing result<int> from errc_t (refs #74) 2021-12-09 20:19:05 +02:00
91c0dd9a74 Merge pull request #73 from kpushkaryov/patch-1
Fix a typo
2021-11-17 06:24:18 +02:00
189fff42fe Fix a typo 2021-11-17 10:59:03 +07:00
3b4045c149 Minor doc update 2021-11-17 04:11:15 +02:00
3d877a1fca Update meta/libraries.json 2021-11-11 04:51:03 +02:00
128bdf9db2 Minor usage section changes 2021-11-11 04:33:06 +02:00
0e84860604 Add another usage subsection 2021-11-11 04:09:49 +02:00
83a306f3bf Update introduction 2021-11-10 20:36:57 +02:00
7dce2e3f42 Change 'wrapping' to 'adapting' 2021-11-10 18:52:41 +02:00
292c6825c6 Add another usage subsection 2021-11-09 22:05:45 +02:00
0d90d3d883 Add myimg_category implementation to usage example 2021-11-08 20:50:41 +02:00
81fec2b171 Add another usage subsection 2021-11-07 23:45:25 +02:00
4e15afe5be Add error handling and programming categories to libraries.json 2021-11-07 20:32:42 +02:00
8d1a866920 Add a usage subsection on wrapping zlib errors 2021-11-05 22:05:23 +02:00
09466c85b4 Add another usage subsection 2021-11-05 20:38:03 +02:00
baef8e50ea Rename 'Usage Examples' to 'Usage', add another subsection 2021-11-05 16:48:33 +02:00
5034f11a3a Add usage examples 2021-11-02 03:12:26 +02:00
f78b036665 Update #if condition 2021-10-29 21:13:10 +03:00
9b0d735040 Add __attribute__((__format__)) to snprintf
This attribute will check format string bugs and is required for clean compile if -Wformat-nonliteral is enabled.
2021-10-29 11:59:03 +01:00
bfebaf53d7 Add static_assert to cmake_subdir_test 2021-10-28 23:48:03 +03:00
8338e80295 Enable syntax hightlighting 2021-10-28 23:17:20 +03:00
2b23aaab16 Add msvc-14.3 to ci.yml 2021-10-28 23:16:53 +03:00
7933300b6f Disable test on g++ 4.x because no std::io_errc 2021-10-11 03:30:50 +03:00
4ec1e54099 Enable error_code construction from enums specializing std::is_error_code_enum. Fixes #70. 2021-10-11 02:02:22 +03:00
5217e58a7d Enable implicit construction for aggregates using {{ ... }} 2021-10-02 22:07:05 +03:00
ce37e23491 Protect against dangling references in op* and value() 2021-10-02 19:16:04 +03:00
420a262733 Fix warnings_test.cpp 2021-10-02 17:25:31 +03:00
e15bccc09b Fix cmake_install_test/main.cpp 2021-10-02 16:57:38 +03:00
bb775c071a Update system_error::what to use error_code::what 2021-10-02 15:00:40 +03:00
01676ae42f Update documentation 2021-10-02 14:47:07 +03:00
eefcc5dcf6 Add error_code::what 2021-10-02 14:41:27 +03:00
f2d3a0decf Update documentation 2021-10-02 01:39:06 +03:00
0ccf08509b Add a constructor taking ErrorCodeEnum and a source location 2021-10-01 23:04:04 +03:00
7a72aee355 Merge branch 'develop' into feature/std-category-2 2021-09-24 23:54:51 +03:00
a8df99e927 Use source_location::to_string in system_error::build_message 2021-09-24 20:40:19 +03:00
85c7d92302 Avoid instantiating the system category in error_code::operator std::error_code 2021-09-24 15:24:45 +03:00
4c201d26b2 Update std_interop_test10 2021-09-24 04:29:29 +03:00
1659dfbeba Avoid instantiating generic_category in error_condition::operator std::error_condition 2021-09-24 04:27:08 +03:00
d2b8b54356 Do not use std::system_category under MinGW and g++ 4.x 2021-09-21 16:35:40 +03:00
41f7ea49cb Do not use std::system_category under VS2013 2021-09-21 16:02:12 +03:00
0b22dc595f Merge branch 'develop' into feature/std-category-2 2021-09-21 15:57:56 +03:00
aab58b0d5b Add std_interop_test10 2021-09-21 15:57:39 +03:00
ad66ea43a3 Revert addition of get_generic_std_category, get_system_std_category (they need this); do not use std::system_category on Cygwin 2021-09-21 15:45:00 +03:00
811564f186 Disable failing comparisons in std_interop_test6; stdlibs are at fault 2021-09-21 15:11:19 +03:00
a7e4879e55 Fix message comparisons in std_interop_test 2021-09-21 15:06:28 +03:00
9b11d864be Add helper functions get_generic_std_category, get_system_std_category 2021-09-21 15:01:44 +03:00
cc6a61b6c5 Convert system_category to std::system_category 2021-09-21 05:34:05 +03:00
9151633c95 Merge branch 'develop' into feature/std-category 2021-09-20 17:41:47 +03:00
5e0db22075 Include errc.hpp in system_error.hpp 2021-09-20 17:41:34 +03:00
60a20eeeb9 Retain old generic_category conversion behavior on g++ 4.8/4.9 2021-09-19 18:44:45 +03:00
1c8128e4cb Merge branch 'develop' into feature/std-category 2021-09-19 18:12:59 +03:00
1879ba6d35 Minor test update 2021-09-19 18:12:46 +03:00
b1dec88674 Convert generic_category to std::generic_category 2021-09-19 17:08:46 +03:00
5fd2535d9f Excise generic_category() references from error_condition 2021-09-19 16:04:16 +03:00
b39f239b3d Update documentation 2021-09-19 15:53:13 +03:00
abb13e707d Minor test fixes 2021-09-19 15:46:03 +03:00
bf34091cfe Add error_code_test2 2021-09-19 15:41:20 +03:00
e3f198e52c Add error_condition::to_string 2021-09-19 15:37:49 +03:00
05581aba03 Add error_condition_test3 2021-09-19 15:26:19 +03:00
47137ad116 Change predefined error_category identifiers to be contiguous for better codegen 2021-09-19 15:04:51 +03:00
c02cd2b004 Add private error_code::equals, use it in error_category::equivalent 2021-09-19 05:24:08 +03:00
c8c5ad1ce5 Rework error_condition::op== to not require the generic_category() instance 2021-09-19 04:49:35 +03:00
361834e49c Minor documentation corrections 2021-09-18 16:57:21 +03:00
360effcf1d Remove static/shared tests, System is header-only 2021-09-18 02:23:21 +03:00
aaa893b5d6 Add mp11 to cmake_subdir_test/CMakeLists.txt 2021-09-18 00:08:30 +03:00
ff0bd3294f Add back predef, winapi needs it 2021-09-17 23:54:33 +03:00
aedadc27ce Update test/cmake_subdir_test/CMakeLists.txt 2021-09-17 21:31:13 +03:00
aad1212cfd Update tests/CMakeLists.txt 2021-09-17 21:15:13 +03:00
c15c2eeb74 Update dependencies in CMakeLists.txt 2021-09-17 21:10:53 +03:00
0ea47dd886 Add CMake jobs to ci.yml 2021-09-17 21:00:18 +03:00
08c12e8ad5 Document result<void, E> 2021-09-17 20:16:01 +03:00
7d3cfdd09a Update test/result_value_construct 2021-09-17 19:54:53 +03:00
15f94537a6 Update test/result_value_access 2021-09-17 19:53:11 +03:00
c0f38e2f3e Update test/result_swap 2021-09-17 19:46:56 +03:00
ac28a8cec9 Update test/result_move_assign 2021-09-17 19:44:58 +03:00
4169ef3ce6 Update test/result_error_construct 2021-09-17 19:36:58 +03:00
ce49a7d1be Update test/result_move_construct 2021-09-17 19:35:20 +03:00
1a4eb29719 Update test/result_error_access 2021-09-17 19:35:05 +03:00
465f6c57da Update test/result_eq 2021-09-17 19:34:44 +03:00
cb8db34d7b Update test/result_copy_assign 2021-09-17 19:34:26 +03:00
2b6a708070 Update test/result_copy_construct 2021-09-17 19:25:20 +03:00
50f84f16dc Add result<void, E> specialization 2021-09-17 19:22:15 +03:00
fd21395802 Minor indentation fixes 2021-09-17 18:50:30 +03:00
cebb011a58 Update indentation in reference 2021-09-17 18:43:30 +03:00
3f67d3def5 Rename throw_exception_from_error_code to throw_exception_from_error 2021-09-17 18:33:04 +03:00
f2b3ae7e2b Document throw_exception_from_error_code 2021-09-17 18:28:53 +03:00
48e56b9874 Update revision history 2021-09-17 18:19:24 +03:00
967b7cbc98 Add result to reference 2021-09-17 18:16:54 +03:00
c8492a705d Use unsafe_get instead of *get_if 2021-09-17 15:47:35 +03:00
a3187439e3 Disable warning in after_main_test 2021-09-16 19:49:17 +03:00
19f9d0c5b4 Fix unused parameter error 2021-09-16 19:43:32 +03:00
d17f7d7fe6 Fix unused variable warning 2021-09-16 19:32:22 +03:00
36843a4e2d Fix unused variable warnings 2021-09-16 19:30:28 +03:00
a6c988181e Include result.hpp in <boost/system.hpp> 2021-09-16 19:25:26 +03:00
10572b7a59 Trim includes in system_error.hpp 2021-09-16 19:21:27 +03:00
fe3d0e6c14 Update all references to <system_error> to refer to Boost.System 2021-09-16 19:16:30 +03:00
ae77563039 Define result in boost::system instead of in boost::result 2021-09-16 18:56:35 +03:00
fd852c675e Add <boost/system/result.hpp> 2021-09-16 18:47:05 +03:00
6156076dab Specify assign in terms of construction and assignment 2021-09-16 18:13:55 +03:00
984f8f1a92 Reorder constructor overloads 2021-09-16 18:04:27 +03:00
b507b2294e Unbreak the loc == 0 case, even though the specification disallows it 2021-09-16 03:12:20 +03:00
39ad22d660 Update reference 2021-09-16 03:07:32 +03:00
3b70265ced Rearrange error_code::failed to improve codegen 2021-09-15 16:42:47 +03:00
a65b91b3fb Merge branch 'develop' into feature/source-location 2021-09-15 16:06:55 +03:00
bed0d59d22 Disable failing tests under g++ 7 -std=c++17 2021-09-15 15:23:52 +03:00
5e642b1d43 Remove error_condition::failed_ in order to prioritise construction efficiency over failed() efficiency (latter is rare for conditions) 2021-09-15 14:54:26 +03:00
b35b47d8c2 Reformat what() message slightly 2021-09-15 13:42:54 +03:00
f21035f8af Move location to the end of what() 2021-09-15 07:58:24 +03:00
cd98f4edd7 Update system_error to incorporate the source location in what() 2021-09-15 07:42:57 +03:00
a9b64a888a Add support for source_location to error_code 2021-09-15 07:03:18 +03:00
bb4b500cfc Update Windows error mapping to match msvc-14.2 <system_error> 2021-09-08 00:48:55 +03:00
d44dab91dc Merge pull request #62 from rohitk5252/patch-2
Update index.html
2021-09-08 00:24:46 +03:00
2b6498ad80 Merge pull request #63 from rohitk5252/patch-3
Update system.adoc
2021-09-08 00:24:30 +03:00
22072bfbc9 Merge pull request #64 from rohitk5252/patch-5
Update Jamfile.v2
2021-09-08 00:24:08 +03:00
65f644d5de Switch ubuntu-16.04 jobs to ubuntu-18.04 2021-09-07 21:57:40 +03:00
f967081d7e Merge pull request #69 from marc-groundctl/map-broken-pipe
Map ERROR_BROKEN_PIPE to errc_t::broken_pipe
2021-09-07 21:34:22 +03:00
19e9f08666 Map ERROR_BROKEN_PIPE to errc_t::broken_pipe 2021-09-07 12:02:02 -04:00
b41139b28e Update documentation 2021-06-16 03:06:26 +03:00
39a19f3c90 Add constexpr to op== against error code enums 2021-06-16 03:06:11 +03:00
b4dd5e98c9 Update appveyor.yml 2021-06-15 20:53:48 +03:00
41e3a7c8af Update appveyor.yml 2021-06-15 06:02:49 +03:00
aee97e91ce Update .travis.yml 2021-06-15 05:34:04 +03:00
98533dedb3 Disable failing tests on g++ 4.8 and 4.9 2021-06-15 05:32:04 +03:00
fe811d1dd1 Update .travis.yml 2021-06-15 03:17:42 +03:00
137ecb4abf Add more tests to std_interop_test7 2021-06-15 03:06:07 +03:00
e5cd7bf852 Placate g++ 6 and earlier 2021-06-15 02:25:13 +03:00
96cd1c0163 Add error_code comparisons against standard error code enums (to resolve the ambiguity when an enum is both standard and ours) 2021-06-15 02:17:26 +03:00
a9da17f2e2 Add std_interop_test9 2021-06-15 01:59:51 +03:00
f26dfd3dd7 Add error_code comparisons against standard error condition enums (to resolve the ambiguity when an enum is both standard and ours) 2021-06-15 01:52:32 +03:00
d09c998eb2 Add std_interop_test8 2021-06-15 01:43:49 +03:00
2374e85dc7 Add std_interop_test7 2021-06-14 22:25:31 +03:00
9167bf8ee8 Update documentation 2021-06-14 21:23:01 +03:00
7f7a9da4d5 Update revision history 2021-06-14 20:07:18 +03:00
67ae4d3c47 Disable std_interop_test5 on g++ 4.8 and 4.9, rather. 2021-06-14 19:04:15 +03:00
ee028e2f9d Remove tabs 2021-06-14 18:28:29 +03:00
7657188802 Disable std_interop_test5 on g++ 4.7 and 4.8; these crash on Xenial, but the real g++ 4.8 on CentOS 7 and Trusty works 2021-06-14 18:07:06 +03:00
210c54b09a Update .travis.yml 2021-06-14 17:36:29 +03:00
87bb5616a8 Update .travis.yml 2021-06-14 17:10:56 +03:00
6de562c79d Update .travis.yml 2021-06-14 15:10:36 +03:00
8efb96350f Clang 6 needs more help with mixed comparisons 2021-06-14 14:44:07 +03:00
88a7be42b5 Update Clang version check 2021-06-14 14:38:26 +03:00
a3225e78e2 Update GCC version check 2021-06-14 14:35:50 +03:00
3c469fe710 Update std_interop_test5.cpp 2021-06-14 04:19:45 +03:00
c2d044f34e Add std_interop_test6 2021-06-14 04:09:24 +03:00
9fdfa6c645 Move code == condition comparisons into error_code, unwrap std::error_code when needed 2021-06-14 04:06:24 +03:00
42a257e17c Add operator<< for error_condition 2021-06-14 03:59:44 +03:00
26d0d32c54 Add std_interop_test5 2021-06-14 03:53:55 +03:00
70b5449e99 Resolve ambiguity for std::error_code == boost::system::error_code 2021-06-14 03:53:00 +03:00
8043ce0278 Resolve ambiguity for std::error_code == boost::system::error_condition 2021-06-14 03:42:50 +03:00
83a2933afa Disable failing test cases on clang-6 and earlier 2021-06-14 02:54:40 +03:00
2e707ca921 Disable -Wstrict-aliasing on g++ 6, really 2021-06-14 02:50:31 +03:00
a6c4b6329c Add a deleted T const& conversion for clang-6 and earlier 2021-06-14 02:35:48 +03:00
5b1909eba4 Disable -Wstrict-aliasing on g++ 6 and below 2021-06-14 02:15:37 +03:00
9dc13fd82a Change value() when holding std::error_code 2021-06-14 02:09:31 +03:00
e9cdb10409 Use std::hash<std::error_code> in hash_value 2021-06-14 01:51:33 +03:00
e625bd0eea Do not access d2_ when <system_error> isn't available; use std::error_code comparisons in op== and op< 2021-06-13 22:48:31 +03:00
66656f7044 Use copy-init instead of direct-init for older clangs 2021-06-13 20:45:50 +03:00
0d8511f571 Use reinterpret_cast to pointer instead of to reference 2021-06-13 20:40:27 +03:00
fbc49bbaa0 Add more tests to std_interop_test3 2021-06-13 19:51:02 +03:00
344eb1e1f8 Rework error_code for better std interop 2021-06-13 19:47:37 +03:00
20b8e90dff Add detail/snprintf.hpp 2021-06-13 18:58:50 +03:00
a0136e570d Update tests/CMakeLists 2021-06-13 18:45:15 +03:00
6586fcb01e Add errc_test3.cpp 2021-06-13 18:42:59 +03:00
b74b1e3c8c Merge branch 'develop' into feature/error-condition 2021-06-13 07:12:16 +03:00
1caaacff57 Split reference into headers 2021-06-13 06:58:48 +03:00
75d5287558 Update copyright 2021-06-13 05:59:04 +03:00
25eaf0fdae Document comparisons as inline friends; use value() and category() instead of val_ and cat_; add subheadings 2021-06-13 05:58:16 +03:00
f43293f451 Increase ToC levels 2021-06-13 05:24:30 +03:00
f8ab3df822 Initialize failed_ in the other two constructors 2021-06-13 05:05:31 +03:00
f6fb85d7d3 Revert "Update Travis to use undefined-sanitizer; disable failed_constexpr_test"
This reverts commit c069ae048f.
2021-06-13 04:59:49 +03:00
9cd9d8732f Revert "Update test/Jamfile"
This reverts commit 3d4c31c213.
2021-06-13 04:59:38 +03:00
1b7fd6854d Revert "Disable failing tests on g++-7/c++17"
This reverts commit b20191f8d7.
2021-06-13 04:58:53 +03:00
610d5f3f78 Revert "Mark error_condition::failed, error_condition::message as deprecated; revert op bool"
This reverts commit 329e72fb92.
2021-06-13 04:56:18 +03:00
88f7c2bf53 Revert "Update documentation"
This reverts commit 8962c9101a.
2021-06-13 04:47:19 +03:00
723daf5d57 Update changelog 2021-06-13 04:39:39 +03:00
3d4c31c213 Update test/Jamfile 2021-06-13 01:13:48 +03:00
c069ae048f Update Travis to use undefined-sanitizer; disable failed_constexpr_test 2021-06-13 01:08:54 +03:00
28e1b919ac Disable failing test 2021-06-12 22:36:12 +03:00
b20191f8d7 Disable failing tests on g++-7/c++17 2021-06-12 22:20:38 +03:00
d019c1cdae Remove detail/is_generic_value.hpp 2021-06-12 22:01:16 +03:00
ff77d4c094 Do not call generic_category() in system_error_category 2021-06-12 21:59:22 +03:00
a21a3050a5 Use nullptr for &generic_category() in error_condition 2021-06-12 21:51:51 +03:00
08d62ac444 Restore Sun workaround 2021-06-12 05:42:03 +03:00
45e9dfeba9 Declare operator std::error_category as BOOST_SYMBOL_VISIBLE 2021-06-12 05:12:58 +03:00
7d9eb384c6 Make error_category comparisons inline friends, to avoid clang 'member call on mutable' constexpr errors 2021-06-12 04:52:21 +03:00
04bfb05b19 Improve the implementation of the std::category conversion 2021-06-12 04:29:13 +03:00
a650f5d676 Remove cmake_install_test dependency on Boost::core 2021-06-12 00:18:26 +03:00
6ab5fd9dac Update ci.yml 2021-06-11 22:15:46 +03:00
ed14d74323 Update .travis.yml 2021-06-11 22:12:35 +03:00
ff9bca96e3 Add boost/system.hpp 2021-06-11 21:15:17 +03:00
8560290b71 Merge pull request #67 from Lastique/feature/add_win32_error_not_supported
Add support for Windows error code ERROR_NOT_SUPPORTED
2021-05-29 03:36:51 +03:00
8b41ff22a6 Update ci.yml 2021-05-29 02:41:45 +03:00
79f9a297cd Update ci.yml 2021-05-29 01:15:51 +03:00
344ea58a77 Added support for Windows error code ERROR_NOT_SUPPORTED.
The error code description reads as "The request is not supported," which
is close to POSIX ENOTSUP "Not supported" and matches MSVC standard library
implementation.
2021-05-29 00:55:40 +03:00
5eae4824ab Update .github/workflows 2021-04-19 21:29:14 +03:00
f502e6cda4 Update .github/workflows 2021-04-19 20:30:50 +03:00
69bc20fb15 Merge pull request #66 from vahtis/vahtis-patch-1
Define BOOST_SYSTEM_DEPRECATED for Oracle Developer Studio
2021-03-22 17:23:49 +02:00
fbf7f4a417 Define BOOST_SYSTEM_DEPRECATED for Oracle Developer Studio
Added Oracle Developer Studio specific define.
2021-03-22 15:38:27 +02:00
a688d7834a add drone config [ci skip] 2021-01-21 19:45:47 +00:00
689e09e86f Merge pull request #65 from eldiener/develop
[skip ci] Add "cxxstd" json field
2021-01-21 18:58:57 +02:00
b92035d4d2 [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. 2021-01-21 11:11:01 -05:00
1ba5c9efc4 Update Jamfile.v2 2021-01-20 16:35:23 +05:30
23db4e8d69 Update system.adoc 2021-01-20 16:31:00 +05:30
189cc0c185 Update index.html
Changed http:// to https://
2021-01-20 16:28:26 +05:30
63a32cea9a Remove deprecation message from windows_error.hpp (closes #57) 2021-01-02 22:16:39 +02:00
3e2cb8975f Update .travis.yml 2021-01-02 16:19:54 +02:00
4e7c88779b Merge branch 'patch-1' of https://github.com/tanzislam/system into feature/pr-56 2020-12-24 02:11:38 +02:00
3ee8200e75 Add .github/workflows 2020-12-24 02:10:50 +02:00
516484a821 Define BOOST_SYSTEM_DEPRECATED for other compilers
Currently compilation fails with Oracle Developer Studio 12.6, for example:

    $ ./b2 toolset=sun threading=multi variant=debug link=static cxxflags=-std=c++11 --with-system
    ...
    "./boost/system/detail/error_condition.hpp", line 96: Error: BOOST_SYSTEM_DEPRECATED is not defined.
    "./boost/system/detail/error_condition.hpp", line 96: Error: No direct declarator preceding ""this function is slated for removal"".
    "./boost/system/detail/error_condition.hpp", line 96: Error: No direct declarator preceding "(".
2020-12-23 23:57:18 +00:00
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
166 changed files with 22061 additions and 3105 deletions

371
.drone.jsonnet Normal file
View File

@ -0,0 +1,371 @@
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
local library = "system";
local triggers =
{
branch: [ "master", "develop", "feature/*" ]
};
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
local asan = { ASAN: '1' };
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "linux",
arch: arch
},
steps:
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'set -e',
'uname -a',
'echo $DRONE_STAGE_MACHINE',
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
] +
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "exec",
trigger: triggers,
platform: {
"os": "darwin",
"arch": arch
},
node: {
"os": osx_version
},
steps: [
{
name: "everything",
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
commands:
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local windows_pipeline(name, image, environment, arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "windows",
arch: arch
},
"steps":
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'cmd /C .drone\\\\drone.bat ' + library,
]
}
]
};
[
linux_pipeline(
"Linux 16.04 GCC 4.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '11' },
"g++-4.8",
),
linux_pipeline(
"Linux 16.04 GCC 4.9",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11' },
"g++-4.9",
),
linux_pipeline(
"Linux 16.04 GCC 5*",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14' },
),
linux_pipeline(
"Linux 18.04 GCC 6",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '11,14' },
"g++-6",
),
linux_pipeline(
"Linux 18.04 GCC 7* 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 18.04 GCC 8",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '11,14,17' },
"g++-8",
),
linux_pipeline(
"Linux 20.04 GCC 9* 32",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32' },
),
linux_pipeline(
"Linux 20.04 GCC 9* 64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '64' },
),
linux_pipeline(
"Linux 20.04 GCC 9* ARM64",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
arch="arm64",
),
linux_pipeline(
"Linux 20.04 GCC 9* S390x",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
arch="s390x",
),
linux_pipeline(
"Linux 20.04 GCC 10 32",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '32' },
"g++-10-multilib",
),
linux_pipeline(
"Linux 20.04 GCC 10 64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '11,14,17,20', ADDRMD: '64' },
"g++-10-multilib",
),
linux_pipeline(
"Linux 22.04 GCC 11* 32",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '32' },
),
linux_pipeline(
"Linux 22.04 GCC 11* 64",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a', ADDRMD: '64' },
),
linux_pipeline(
"Linux 22.04 GCC 12 32",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' },
"g++-12-multilib",
),
linux_pipeline(
"Linux 22.04 GCC 12 64",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' },
"g++-12-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 32 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 64 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 32 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + ubsan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + asan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '11' },
"clang-3.5",
),
linux_pipeline(
"Linux 16.04 Clang 3.6",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '11,14' },
"clang-3.6",
),
linux_pipeline(
"Linux 16.04 Clang 3.7",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '11,14' },
"clang-3.7",
),
linux_pipeline(
"Linux 16.04 Clang 3.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '11,14' },
"clang-3.8",
),
linux_pipeline(
"Linux 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '11,14,17,20' },
"clang-13",
),
linux_pipeline(
"Linux 22.04 Clang 14",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '11,14,17,20' },
"clang-14",
),
linux_pipeline(
"Linux 22.04 Clang 15",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' },
"clang-15",
),
linux_pipeline(
"Linux 24.04 Clang 16",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
"clang-16",
),
linux_pipeline(
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
"clang-17",
),
linux_pipeline(
"Linux 24.04 Clang 18 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan,
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 18 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan,
"clang-18",
),
linux_pipeline(
"Linux 24.10 Clang 19",
"cppalliance/droneubuntu2410:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
"clang-19",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + asan,
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + ubsan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,17,20,2b' } + asan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
windows_pipeline(
"Windows VS2015 msvc-14.0",
"cppalliance/dronevs2015",
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' },
),
windows_pipeline(
"Windows VS2017 msvc-14.1",
"cppalliance/dronevs2017",
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
),
windows_pipeline(
"Windows VS2019 msvc-14.2",
"cppalliance/dronevs2019",
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2022 msvc-14.3",
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
]

23
.drone/drone.bat Normal file
View File

@ -0,0 +1,23 @@
@REM Copyright 2022 Peter Dimov
@REM Distributed under the Boost Software License, Version 1.0.
@REM https://www.boost.org/LICENSE_1_0.txt
@ECHO ON
set LIBRARY=%1
set DRONE_BUILD_DIR=%CD%
set BOOST_BRANCH=develop
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
python tools/boostdep/depinst/depinst.py %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

25
.drone/drone.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
set -ex
export PATH=~/.local/bin:/usr/local/bin:$PATH
DRONE_BUILD_DIR=$(pwd)
BOOST_BRANCH=develop
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
python tools/boostdep/depinst/depinst.py $LIBRARY
./bootstrap.sh
./b2 -d0 headers
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}

637
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,637 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "11"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-4.8
- toolset: gcc-5
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-5
- toolset: gcc-6
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: g++-6
- toolset: gcc-7
cxxstd: "11,14,17"
os: ubuntu-latest
container: ubuntu:18.04
- toolset: gcc-8
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-8
- toolset: gcc-9
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
- toolset: gcc-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
install: g++-10
- toolset: gcc-11
cxxstd: "11,14,17,2a"
os: ubuntu-22.04
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
os: ubuntu-22.04
install: g++-12
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.04
install: g++-13
- toolset: gcc-14
cxxstd: "11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.04
install: g++-14
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
os: ubuntu-latest
container: ubuntu:18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.10
os: ubuntu-latest
install: clang-19
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-15
runs-on: ${{matrix.os}}
container:
image: ${{matrix.container}}
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
defaults:
run:
shell: bash
steps:
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++ curl xz-utils
- name: Install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
run: |
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: "14"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release

View File

@ -4,9 +4,7 @@
language: cpp
sudo: false
dist: trusty
dist: xenial
branches:
only:
@ -26,7 +24,26 @@ matrix:
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
addons:
apt:
packages:
- g++-multilib
- os: linux
arch: arm64
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
arch: ppc64le
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
- os: linux
arch: s390x
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
compiler: g++-4.4
@ -49,99 +66,23 @@ matrix:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
dist: trusty
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
dist: bionic
compiler: g++-11
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-11 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-4.7
- g++-11
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- 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
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
- sourceline: "ppa:ubuntu-toolchain-r/test"
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -150,6 +91,7 @@ matrix:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
@ -158,229 +100,103 @@ matrix:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
compiler: clang++-12
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-3.5
- libstdc++-4.9-dev
- clang-12
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- 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
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- os: linux
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-8
- 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
addons:
apt:
packages:
- clang-6.0
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: linux
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: freebsd
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode7.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode8.3
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
osx_image: xcode9.4
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
osx_image: xcode10.1
- os: osx
osx_image: xcode11.3
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: osx
osx_image: xcode12.2
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
- os: linux
compiler: g++
env: CMAKE_SUBDIR_TEST=1
env: CMAKE=1
script:
- cd libs/system/test/cmake_subdir_test && mkdir __build__ && cd __build__
- mkdir __build__ && cd __build__
- cmake -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- cmake --build . --target tests
- ctest --output-on-failure --no-tests=error
- os: linux
env: CMAKE=1 BUILD_SHARED_LIBS=ON
script:
- mkdir __build__ && cd __build__
- cmake -DBUILD_SHARED_LIBS=ON -DBOOST_INCLUDE_LIBRARIES=system -DBUILD_TESTING=ON ..
- cmake --build . --target tests
- ctest --output-on-failure --no-tests=error
- 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_INCLUDE_LIBRARIES=system -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 ..
@ -395,7 +211,7 @@ install:
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined define=UBSAN=1 debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:

View File

@ -1,12 +1,10 @@
# Copyright 2018 Mike Dev
# Copyright 2018-2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
# https://www.boost.org/LICENSE_1_0.txt
# Partial (add_subdirectory only) and experimental CMake support
# Subject to change; please do not rely on the contents of this file yet
cmake_minimum_required(VERSION 3.8...3.20)
cmake_minimum_required(VERSION 3.5)
project(BoostSystem LANGUAGES CXX)
project(boost_system VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_system INTERFACE)
add_library(Boost::system ALIAS boost_system)
@ -14,7 +12,27 @@ add_library(Boost::system ALIAS boost_system)
target_include_directories(boost_system INTERFACE include)
target_link_libraries(boost_system
INTERFACE
Boost::config
Boost::winapi
INTERFACE
Boost::assert
Boost::config
Boost::throw_exception
Boost::variant2
Boost::winapi
)
target_compile_features(boost_system INTERFACE cxx_std_11)
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
file(GLOB_RECURSE boost_system_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_system_IDEFILES} PREFIX "Header Files")
list(APPEND boost_system_IDEFILES extra/boost_system.natvis)
target_sources(boost_system PRIVATE ${boost_system_IDEFILES})
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

25
README.md Normal file
View File

@ -0,0 +1,25 @@
# Boost.System
The Boost.System library, part of [Boost C++ Libraries](https://boost.org),
implements an extensible framework for error reporting in the form of an
`error_code` class and supporting facilities.
It has been proposed for the C++11 standard, has been accepted, and
is now available as part of the standard library in the `<system_error>`
header. However, the Boost implementation has continued to evolve and
gain enhancements and additional functionality, such as support for
attaching [source locations](https://www.boost.org/doc/libs/release/libs/assert/doc/html/assert.html#source_location_support)
to `error_code`, and a `result<T>` class that can carry either a value
or an error code.
See [the documentation of System](http://boost.org/libs/system) for more
information.
Since `<system_error>` is a relatively undocumented portion of the C++
standard library, the documentation of Boost.System may be useful to you
even if you use the standard components.
## License
Distributed under the
[Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

View File

@ -14,31 +14,27 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
- 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,clang-win
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 2015
TOOLSET: msvc-14.1
CXXSTD: 14,17,latest
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17,latest
ADDRMD: 64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ADDPATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_SUBDIR: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE_INSTALL: 1
install:
- set BOOST_BRANCH=develop
@ -58,4 +54,27 @@ test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
- if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
- if not "%CMAKE%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=system -DBoost_VERBOSE=ON ..
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Debug & ctest --output-on-failure --no-tests=error -j 3 -C Debug
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Release & ctest --output-on-failure --no-tests=error -j 3 -C Release
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config MinSizeRel & ctest --output-on-failure --no-tests=error -j 3 -C MinSizeRel
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -j 3 -C RelWithDebInfo
- if not "%CMAKE_SUBDIR%" == "" cd libs/system/test/cmake_subdir_test && mkdir __build__ && cd __build__
- if not "%CMAKE_SUBDIR%" == "" cmake ..
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config MinSizeRel && cmake --build . --target check --config MinSizeRel
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config RelWithDebInfo && cmake --build . --target check --config RelWithDebInfo
- if not "%CMAKE_INSTALL%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DBOOST_INCLUDE_LIBRARIES=system -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Release
- if not "%CMAKE_INSTALL%" == "" cd ../libs/system/test/cmake_install_test && mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Release && cmake --build . --target check --config Release

25
build.jam Normal file
View File

@ -0,0 +1,25 @@
# Copyright 2023-2024 René Ferdinand Rivera Morell
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/config//boost_config
/boost/throw_exception//boost_throw_exception
/boost/variant2//boost_variant2
/boost/winapi//boost_winapi
;
project /boost/system ;
explicit
[ alias boost_system : build//boost_system ]
[ alias all : boost_system test ]
;
call-if : boost-library system
: install boost_system
;

View File

@ -1,25 +1,20 @@
# Boost System Library Build Jamfile
# (C) Copyright Beman Dawes 2002, 2006
# Copyright 2002, 2006 Beman Dawes
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
# https://www.boost.org/LICENSE_1_0.txt
# See library home page at http://www.boost.org/libs/system
# See library home page at https://www.boost.org/libs/system
project boost/system
: source-location ../src
: usage-requirements # pass these requirement to dependents (i.e. users)
project
: common-requirements
<include>../include
<library>$(boost_dependencies)
<link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
<define>BOOST_SYSTEM_NO_LIB=1
;
SOURCES = error_code ;
lib boost_system
: $(SOURCES).cpp
: <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
<link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
;
boost-install boost_system ;
lib boost_system : ../src/$(SOURCES).cpp ;

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

@ -4,19 +4,22 @@ 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
https://www.boost.org/LICENSE_1_0.txt
////
# Boost.System: Extensible Error Reporting
Beman Dawes, Christopher Kohlhoff, Peter Dimov
:toc: left
:toclevels: 3
:toclevels: 4
:idprefix:
:docinfo: private-footer
:source-highlighter: rouge
:source-language: c++
:leveloffset: +1
include::system/introduction.adoc[]
include::system/usage.adoc[]
include::system/changes.adoc[]
include::system/rationale.adoc[]
include::system/reference.adoc[]

View File

@ -1,16 +1,115 @@
////
Copyright 2018 Peter Dimov
Copyright 2018-2022 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
https://www.boost.org/LICENSE_1_0.txt
////
[#changes]
# Release History
# Revision History
:idprefix:
## Changes in Boost 1.86
* Support `result<T> & fv`, where `fv` returns `void`.
* Support `result<void> &= fv;`, where `fv` returns `void`.
## Changes in Boost 1.85
* {cpp}03 is no longer supported; a {cpp}11 compiler is required. (This includes GCC 4.8 or later, and MSVC 14.0 (VS 2015) or later.)
* The deprecated header `boost/system/cygwin_error.hpp` has been removed.
* The original and obsolete (32 bit) MinGW is no longer supported. MinGW-w64 (both 64 and 32 bit) is still supported.
* `operator&` now works for `result<void>` (by way of taking a nullary function.)
* Added `operator|=` for `result`.
## Changes in Boost 1.84
* Added support for `result<U&, E>`.
* Added `operator|` for `result`.
* Added `operator&` for `result`.
* Added `operator&=` for `result`.
## Changes in Boost 1.81
* The macro `BOOST_SYSTEM_DISABLE_THREADS` can now be defined to disable
the use of `<mutex>` (e.g. on single-threaded libstdc++).
* Added `value_type`, `error_type`, `in_place_value`, `in_place_error`
to `result<>`.
* Added `emplace` to `result<>`.
## Changes in Boost 1.80
* When an `error_code` is converted to `std::error_code` and then back
to `error_code`, the original is now restored, if possible.
* Reworked the conversion from `error_category` to `std::error_category`
to avoid the one-time allocation that shows up on leak checkers.
* Added a constructor that allows replacing the source location of an
`error_code`, and a corresponding `assign`.
* Added a converting constructor to `result`.
## Changes in Boost 1.79
* Added a `boost::source_location` parameter to `throw_exception_from_error`.
* Added `throw_exception_from_error` overloads for `errc::errc_t`,
`std::error_code`, `std::errc`, `std::exception_ptr`.
* `result<T>::value` now automatically supplies `BOOST_CURRENT_LOCATION` to
`throw_exception_from_error` via a default argument.
* Added an `errc::make_error_code` overload taking a source location.
## Changes in Boost 1.78
* Added support for source locations to `error_code`.
* Added `error_code::to_string`, `error_condition::to_string`, `error_code::what`.
* `system_error::what()` now contains the source location, if present.
* Added `result<T, E = error_code>`, a class holding either a value or an
error, defined in `<boost/system/result.hpp>`.
## Changes in Boost 1.77
* The conversion operator from `error_category` to `std::error_category`
has been improved and no longer requires `<map>` or `<mutex>`.
* The comparison operators of `error_category` are now inline friends
instead of member functions (a side effect of the previous change.)
* `error_condition` now defers calling `generic_category()` to avoid
instantiating the object until it's actually needed.
* `error_condition::failed` and `error_condition::message` have been
undeprecated, and `operator bool()` now once again returns `failed()`.
* The system category now doesn't call `generic_category()`, to avoid
instantiating the object.
* The return value of `default_error_condition` changes in some cases into
an `error_condition` from the generic category, instead of from the system
category. This happens on POSIX when the input `error_code` is from
the system category and does not correspond to any `errc_t` value.
* The interoperability of `error_code` and `std::error_code` has been
improved substantially. It is now possible to construct
`boost::system::error_code` from `std::error_code`, and it's possible
to pass `boost::system::error_code` to functions taking `std::error_code&`.
* A stream insertion operator for `error_condition` has been added.
## Changes in Boost 1.76
* `windows_error.hpp` is no longer deprecated.
## 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

@ -1,5 +1,5 @@
////
Copyright 2018 Peter Dimov
Copyright 2018-2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
@ -14,6 +14,6 @@ http://www.boost.org/LICENSE_1_0.txt
This documentation is
* Copyright 2003-2017 Beman Dawes
* Copyright 2018 Peter Dimov
* Copyright 2018-2022 Peter Dimov
and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@ -1,6 +1,6 @@
////
Copyright 2003-2017 Beman Dawes
Copyright 2018 Peter Dimov
Copyright 2018, 2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
@ -12,39 +12,67 @@ http://www.boost.org/LICENSE_1_0.txt
# Introduction
:idprefix: intro_
Error conditions originating from the operating system or other low-level
application program interfaces (API's) are typically reported via an integer
representing an error code. When these low-level API calls are wrapped in
portable code, such as in a portable library, some users want to deal with the
error codes in portable ways. Other users need to get at the system specific
error codes, so they can deal with system specific needs. The Boost System
library provides simple, light-weight `error_code` objects that encapsulate
system-specific error code values, yet also provide access to more abstract
and portable error conditions via `error_condition` objects.
Errors originating from the operating system or other low-level application
program interfaces (APIs) are typically reported via an integer representing
an error code, either by returning the code directly from the function (e.g.
`pthread_mutex_init`) or by using a side channel such as the `errno`
pseudo-variable under POSIX or `GetLastError()` under Windows.
Because `error_code` objects can represent errors from sources other than the
operating system, including user-defined sources, each `error_code` and
`error_condition` has an associated `error_category`.
However, these integer error values can only be interpreted when their source
is known. The value 5 under Windows means `ERROR_ACCESS_DENIED` when returned
by `GetLastError()`, but `EIO` when retrieved from `errno`. And conversely,
the same error condition "access denied" is represented by the value 5 when
returned by `GetLastError()` and 13 (`EACCES`) when retrieved from `errno`.
An exception class, `system_error`, is provided. Derived from
`std::runtime_error`, it captures the underlying `error_code` for the problem
causing the exception so that this important information is not lost.
This means that in order for code to be able to handle errors from both
sources (to retrieve a text message describing the error, or to check whether
the error means "access denied"), it needs to know where the integer error
value originated. For this to be possible, the integer error value needs to
be accompanied by a piece of information identifying the source.
While exceptions are the preferred {cpp} default error code reporting
mechanism, users of libraries dependent on low-level API's often need overloads
reporting error conditions via error code arguments and/or return values rather
than via throwing exceptions. Otherwise, when errors are not exceptional
occurrences and must be dealt with as they arise, programs become littered with
try/catch blocks, unreadable, and inefficient. The Boost System library
supports both error reporting by exception and by error code.
Boost.System provides a framework in which this is possible. Errors are
represented by a class `error_code` which contains both the error value and
a pointer to their source (called "category"), represented as a class derived
from `error_category`.
In addition to portable errors codes and conditions supported by the
`error_code.hpp` header, system-specific headers support the Cygwin, Linux,
and Windows platforms. These headers are effectively no-ops if included for
platforms other than their intended target.
The category provides member functions such as `message`, which returns a text
message for a specific error value, and `equivalent`, which can be used to test
whether a specific error value correspond to an error condition such as "access
denied". `error_code` uses these category-provided functions in the
implementation of its `message` and `operator==` member functions.
Boost.System is part of the {cpp}11 Standard Library.
A number of changes, particularly to names, were made by the C++ committee
during standardization. The Boost implementation has been tracking those changes.
See <<#ref_deprecated_names,Deprecated Names>> for synonyms provided to prevent
breakage of existing user code.
Boost.System contains two predefined category classes, the generic category
(a reference to which is returned by `generic_category()`) and the system
category (`system_category()`). The generic category represents the error
values of the portable subset of `errno` values defined by the POSIX standard,
whereas the system category is OS dependent. Under POSIX, the system category
represents the `errno` values returned by the OS APIs (a superset of those in
the generic category), whereas under Windows, the system category represents
the error values returned by `GetLastError()`.
The framework is extensible. Users can define their own categories by
deriving a class from `error_category` and implementing a function that
returns a reference to an instance of it. This capability is useful both for
describing library-defined error values, and for adapting existing C API
libraries that return integer error values.
For those who prefer error reporting via exceptions, Boost.System provides
a standard exception class `system_error` that stores an `error_code`.
Boost.System was standardized in {cpp}11 as `<system_error>`. For a while,
the two were equivalent, but Boost.System has evolved since then and now
contains a number of extensions over its standard sibling:
* A non-allocating overload of `message`;
* Support for nonzero error codes meaning success, via the `failed` member
functions;
* Support for 64 bit category identifiers, as a solution to the problem
that sometimes it's not possible to ensure that only one instance of a
category exists in the program;
* Support for attaching source locations (file/line/function) to error codes;
* A class `result<T>` that can be used to return either a value or an error
code from a function;
* Various other minor improvements.
`boost::system::error_code` can be converted to, and constructed from,
`std::error_code`.

File diff suppressed because it is too large Load Diff

1414
doc/system/usage.adoc Normal file

File diff suppressed because it is too large Load Diff

53
extra/boost_system.natvis Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="boost::system::error_category">
<DisplayString Condition="id_ == 0xb2ab117a257edfd0">[generic]</DisplayString>
<DisplayString Condition="id_ == 0xb2ab117a257edfd1">[system]</DisplayString>
<DisplayString Condition="id_ == 0xb2ab117a257edfd2">[interop]</DisplayString>
<DisplayString Condition="id_ != 0">[{id_,x}]</DisplayString>
<DisplayString>@{((uintptr_t)this),x}</DisplayString>
</Type>
<Type Name="boost::system::error_code">
<DisplayString Condition="lc_flags_ == 0">{d1_.val_} [system] ✓</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==1">{((std::error_code*)d2_)->_Myval} [std:future]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==3">{((std::error_code*)d2_)->_Myval} [std:generic]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==5">{((std::error_code*)d2_)->_Myval} [std:iostream]</DisplayString>
<DisplayString Condition="lc_flags_ == 1 &amp;&amp; ((std::error_code*)d2_)->_Mycat->_Addr==7">{((std::error_code*)d2_)->_Myval} [std:system]</DisplayString>
<DisplayString Condition="lc_flags_ == 1">{((std::error_code*)d2_)->_Myval} std@{((uintptr_t)((std::error_code*)d2_)->_Mycat),x}</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd0 &amp;&amp;
(lc_flags_ == 2 || (lc_flags_ &gt; 3 &amp;&amp; ( lc_flags_ % 2 == 0 )))">{d1_.val_} [generic] ✓</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd1 &amp;&amp;
(lc_flags_ == 2 || (lc_flags_ &gt; 3 &amp;&amp; ( lc_flags_ % 2 == 0 )))">{d1_.val_} [system] ✓</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd2 &amp;&amp;
(lc_flags_ == 2 || (lc_flags_ &gt; 3 &amp;&amp; ( lc_flags_ % 2 == 0 )))">{d1_.val_} [interop] ✓</DisplayString>
<DisplayString Condition="d1_.cat_->id_ != 0 &amp;&amp;
(lc_flags_ == 2 || (lc_flags_ &gt; 3 &amp;&amp; ( lc_flags_ % 2 == 0 )))">{d1_.val_} [{d1_.cat_->id_,x}] ✓</DisplayString>
<DisplayString Condition=
"lc_flags_ == 2 || (lc_flags_ &gt; 3 &amp;&amp; ( lc_flags_ % 2 == 0 ))">{d1_.val_} @{((uintptr_t)d1_.cat_),x} ✓</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd0 &amp;&amp;
(lc_flags_ &gt;= 3 &amp;&amp; ( lc_flags_ % 2 == 1 ))">{d1_.val_} [generic]</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd1 &amp;&amp;
(lc_flags_ &gt;= 3 &amp;&amp; ( lc_flags_ % 2 == 1 ))">{d1_.val_} [system]</DisplayString>
<DisplayString Condition="d1_.cat_->id_ == 0xb2ab117a257edfd2 &amp;&amp;
(lc_flags_ &gt;= 3 &amp;&amp; ( lc_flags_ % 2 == 1 ))">{d1_.val_} [interop]</DisplayString>
<DisplayString Condition="d1_.cat_->id_ != 0 &amp;&amp;
(lc_flags_ &gt;= 3 &amp;&amp; ( lc_flags_ % 2 == 1 ))">{d1_.val_} [{d1_.cat_->id_,x}]</DisplayString>
<DisplayString Condition=
"lc_flags_ &gt;= 3 &amp;&amp; ( lc_flags_ % 2 == 1 )">{d1_.val_} @{((uintptr_t)d1_.cat_),x}</DisplayString>
<Expand>
<Item Name="std::error_code" Condition="lc_flags_ == 1">(std::error_code*)d2_</Item>
<Item Name="[location]" Condition="lc_flags_ &gt; 3">*((boost::source_location*)(lc_flags_ &amp; ~1))</Item>
</Expand>
</Type>
<Type Name="boost::system::result&lt;*,*&gt;">
<DisplayString>{v_}</DisplayString>
</Type>
</AutoVisualizer>

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

14
include/boost/system.hpp Normal file
View File

@ -0,0 +1,14 @@
#ifndef BOOST_SYSTEM_HPP_INCLUDED
#define BOOST_SYSTEM_HPP_INCLUDED
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/system/result.hpp>
#endif // #ifndef BOOST_SYSTEM_HPP_INCLUDED

View File

@ -1,56 +0,0 @@
// boost/system/cygwin_error.hpp -------------------------------------------//
// Copyright Beman Dawes 2007
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// See library home page at http://www.boost.org/libs/system
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
// This header is effectively empty for compiles on operating systems where
// it is not applicable.
# ifdef __CYGWIN__
#include <boost/system/error_code.hpp>
namespace boost
{
namespace system
{
// To construct an error_code after a API error:
//
// error_code( errno, system_category() )
// User code should use the portable "posix" enums for POSIX errors; this
// allows such code to be portable to non-POSIX systems. For the non-POSIX
// errno values that POSIX-based systems typically provide in addition to
// POSIX values, use the system specific enums below.
namespace cygwin_error
{
enum cygwin_errno
{
no_net = ENONET,
no_package = ENOPKG,
no_share = ENOSHARE
};
} // namespace cygwin_error
template<> struct is_error_code_enum<cygwin_error::cygwin_errno>
{ static const bool value = true; };
namespace cygwin_error
{
inline error_code make_error_code( cygwin_errno e )
{ return error_code( e, system_category() ); }
}
}
}
#endif // __CYGWIN__
#endif // BOOST_SYSTEM_CYGWIN_ERROR_HPP

View File

@ -0,0 +1,32 @@
#ifndef BOOST_SYSTEM_DETAIL_APPEND_INT_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_APPEND_INT_HPP_INCLUDED
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/system/detail/snprintf.hpp>
#include <string>
//
namespace boost
{
namespace system
{
namespace detail
{
inline void append_int( std::string& s, int v )
{
char buffer[ 32 ];
detail::snprintf( buffer, sizeof( buffer ), ":%d", v );
s += buffer;
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_APPEND_INT_HPP_INCLUDED

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

@ -1,7 +1,7 @@
#ifndef BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
// Copyright 2018 Peter Dimov
// Copyright 2018-2022 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)
@ -11,26 +11,16 @@
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
// BOOST_SYSTEM_HAS_SYSTEM_ERROR
#if !defined(BOOST_NO_CXX11_HDR_SYSTEM_ERROR)
# define BOOST_SYSTEM_HAS_SYSTEM_ERROR
#endif
#if BOOST_WORKAROUND(BOOST_GCC, < 40600)
// g++ 4.4's <map> is not good enough
# 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
// The macro BOOST_SYSTEM_DISABLE_THREADS can be defined on configurations
// that provide <system_error> and <atomic>, but not <mutex>, such as the
// single-threaded libstdc++.
//
// https://github.com/boostorg/system/issues/92
// BOOST_SYSTEM_NOEXCEPT
// Retained for backward compatibility
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
#define BOOST_SYSTEM_NOEXCEPT noexcept
// BOOST_SYSTEM_HAS_CONSTEXPR
@ -48,4 +38,46 @@
# define BOOST_SYSTEM_CONSTEXPR
#endif
// BOOST_SYSTEM_DEPRECATED
#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))
#elif defined(__sun)
# define BOOST_SYSTEM_DEPRECATED(msg) __attribute__((deprecated(msg)))
#else
# define BOOST_SYSTEM_DEPRECATED(msg)
#endif
// BOOST_SYSTEM_CLANG_6
// Android NDK r18b has Clang 7.0.2 that still needs the workaround
// https://github.com/boostorg/system/issues/100
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11) || (defined(__ANDROID__) && __clang_major__ == 7))
# define BOOST_SYSTEM_CLANG_6
#endif
//
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 50000
# define BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY
#endif
#if defined(__CYGWIN__) || defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER == 1800) || (defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 90000)
// Under Cygwin (and MinGW!), std::system_category() is POSIX
// Under VS2013, std::system_category() isn't quite right
// Under libstdc++ before 7.4, before 8.3, before 9.1, default_error_condition
// for the system category returns a condition from the system category
# define BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY
#endif
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED

View File

@ -0,0 +1,23 @@
#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
#include <type_traits>
namespace boost
{
namespace system
{
namespace detail
{
using std::enable_if;
} // 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,183 @@
#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 <boost/config/workaround.hpp>
#include <string>
#include <functional>
#include <cstddef>
#include <system_error>
#include <atomic>
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 );
class std_category;
} // namespace detail
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
#pragma warning(push)
#pragma warning(disable: 4351) // new behavior: elements of array will be default initialized
#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 );
friend class error_code;
friend class error_condition;
public:
error_category( error_category const & ) = delete;
error_category& operator=( error_category const & ) = delete;
private:
boost::ulong_long_type id_;
static std::size_t const stdcat_size_ = 4 * sizeof( void const* );
union
{
mutable unsigned char stdcat_[ stdcat_size_ ];
void const* stdcat_align_;
};
mutable std::atomic< unsigned > sc_init_;
protected:
~error_category() = default;
constexpr error_category() noexcept: id_( 0 ), stdcat_(), sc_init_()
{
}
explicit constexpr error_category( boost::ulong_long_type id ) noexcept: id_( id ), stdcat_(), sc_init_()
{
}
public:
virtual const char * name() const noexcept = 0;
virtual error_condition default_error_condition( int ev ) const noexcept;
virtual bool equivalent( int code, const error_condition & condition ) const noexcept;
virtual bool equivalent( const error_code & code, int condition ) const noexcept;
virtual std::string message( int ev ) const = 0;
virtual char const * message( int ev, char * buffer, std::size_t len ) const noexcept;
virtual bool failed( int ev ) const noexcept
{
return ev != 0;
}
friend BOOST_SYSTEM_CONSTEXPR bool operator==( error_category const & lhs, error_category const & rhs ) noexcept
{
return rhs.id_ == 0? &lhs == &rhs: lhs.id_ == rhs.id_;
}
friend BOOST_SYSTEM_CONSTEXPR bool operator!=( error_category const & lhs, error_category const & rhs ) noexcept
{
return !( lhs == rhs );
}
friend BOOST_SYSTEM_CONSTEXPR bool operator<( error_category const & lhs, error_category const & rhs ) noexcept
{
if( lhs.id_ < rhs.id_ )
{
return true;
}
if( lhs.id_ > rhs.id_ )
{
return false;
}
if( rhs.id_ != 0 )
{
return false; // equal
}
return std::less<error_category const *>()( &lhs, &rhs );
}
void init_stdcat() const;
# if defined(__SUNPRO_CC) // trailing __global is not supported
operator std::error_category const & () const;
# else
operator std::error_category const & () const BOOST_SYMBOL_VISIBLE;
# endif
};
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
#pragma warning(pop)
#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 ) + 0x257EDFD0;
static const boost::ulong_long_type system_category_id = generic_category_id + 1;
static const boost::ulong_long_type interop_category_id = generic_category_id + 2;
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
{
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,166 @@
#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/system/detail/snprintf.hpp>
#include <boost/system/detail/config.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 noexcept
{
return error_condition( ev, *this );
}
inline bool error_category::equivalent( int code, const error_condition & condition ) const noexcept
{
return default_error_condition( code ) == condition;
}
inline bool error_category::equivalent( const error_code & code, int condition ) const noexcept
{
return code.equals( condition, *this );
}
inline char const * error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
{
if( len == 0 )
{
return buffer;
}
if( len == 1 )
{
buffer[0] = 0;
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
try
#endif
{
detail::snprintf( buffer, len, "%s", this->message( ev ).c_str() );
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
catch( ... )
{
detail::snprintf( buffer, len, "No message text available for error %d", ev );
return buffer;
}
#endif
}
} // namespace system
} // namespace boost
// interoperability with std::error_code, std::error_condition
#include <boost/system/detail/std_category_impl.hpp>
#include <boost/system/detail/mutex.hpp>
#include <new>
namespace boost
{
namespace system
{
inline void error_category::init_stdcat() const
{
static_assert( sizeof( stdcat_ ) >= sizeof( boost::system::detail::std_category ), "sizeof(stdcat_) is not enough for std_category" );
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
// no alignof
#else
static_assert( alignof( decltype(stdcat_align_) ) >= alignof( boost::system::detail::std_category ), "alignof(stdcat_) is not enough for std_category" );
#endif
// detail::mutex has a constexpr default constructor,
// and therefore guarantees static initialization, on
// everything except VS 2013 (msvc-12.0)
static system::detail::mutex mx_;
system::detail::lock_guard<system::detail::mutex> lk( mx_ );
if( sc_init_.load( std::memory_order_acquire ) == 0 )
{
::new( static_cast<void*>( stdcat_ ) ) boost::system::detail::std_category( this, system::detail::id_wrapper<0>() );
sc_init_.store( 1, std::memory_order_release );
}
}
#if defined( BOOST_GCC ) && BOOST_GCC >= 40800 && BOOST_GCC < 70000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
inline BOOST_NOINLINE error_category::operator std::error_category const & () const
{
if( id_ == detail::generic_category_id )
{
// This condition must be the same as the one in error_condition.hpp
#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
static const boost::system::detail::std_category generic_instance( this, system::detail::id_wrapper<0x1F4D3>() );
return generic_instance;
#else
return std::generic_category();
#endif
}
if( id_ == detail::system_category_id )
{
// This condition must be the same as the one in error_code.hpp
#if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY)
static const boost::system::detail::std_category system_instance( this, system::detail::id_wrapper<0x1F4D7>() );
return system_instance;
#else
return std::system_category();
#endif
}
if( sc_init_.load( std::memory_order_acquire ) == 0 )
{
init_stdcat();
}
return *static_cast<boost::system::detail::std_category const*>( static_cast<void const*>( stdcat_ ) );
}
#if defined( BOOST_GCC ) && BOOST_GCC >= 40800 && BOOST_GCC < 70000
#pragma GCC diagnostic pop
#endif
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CATEGORY_IMPL_HPP_INCLUDED

View File

@ -0,0 +1,659 @@
#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-2021
//
// 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_code_enum.hpp>
#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/system_category_impl.hpp>
#include <boost/system/detail/interop_category.hpp>
#include <boost/system/detail/enable_if.hpp>
#include <boost/system/detail/is_same.hpp>
#include <boost/system/detail/append_int.hpp>
#include <boost/system/detail/snprintf.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/system/detail/std_category.hpp>
#include <boost/assert/source_location.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <ostream>
#include <new>
#include <cstdio>
#include <system_error>
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
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.
bool operator==( const error_code & code, const error_condition & condition ) noexcept;
std::size_t hash_value( error_code const & ec );
class error_code
{
private:
friend bool operator==( const error_code & code, const error_condition & condition ) noexcept;
friend std::size_t hash_value( error_code const & ec );
private:
struct data
{
int val_;
const error_category * cat_;
};
union
{
data d1_;
unsigned char d2_[ sizeof(std::error_code) ];
};
// 0: default constructed, d1_ value initialized
// 1: holds std::error_code in d2_
// 2: holds error code in d1_, failed == false
// 3: holds error code in d1_, failed == true
// >3: pointer to source_location, failed_ in lsb
boost::uintptr_t lc_flags_;
private:
char const* category_name() const noexcept
{
// return category().name();
if( lc_flags_ == 0 )
{
// must match detail::system_error_category::name()
return "system";
}
else if( lc_flags_ == 1 )
{
// must match detail::interop_error_category::name()
return "std:unknown";
}
else
{
return d1_.cat_->name();
}
}
public:
// constructors:
constexpr error_code() noexcept:
d1_(), lc_flags_( 0 )
{
}
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) noexcept:
d1_(), lc_flags_( 2 + detail::failed_impl( val, cat ) )
{
d1_.val_ = val;
d1_.cat_ = &cat;
}
error_code( int val, const error_category & cat, source_location const * loc ) noexcept:
d1_(), lc_flags_( ( loc? reinterpret_cast<boost::uintptr_t>( loc ): 2 ) | +detail::failed_impl( val, cat ) )
{
d1_.val_ = val;
d1_.cat_ = &cat;
}
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
typename detail::enable_if<
is_error_code_enum<ErrorCodeEnum>::value
|| std::is_error_code_enum<ErrorCodeEnum>::value
>::type* = 0 ) noexcept: d1_(), lc_flags_( 0 )
{
*this = make_error_code( e );
}
error_code( error_code const& ec, source_location const * loc ) noexcept:
d1_(), lc_flags_( 0 )
{
*this = ec;
if( ec.lc_flags_ != 0 && ec.lc_flags_ != 1 )
{
lc_flags_ = ( loc? reinterpret_cast<boost::uintptr_t>( loc ): 2 ) | ( ec.lc_flags_ & 1 );
}
}
error_code( std::error_code const& ec ) noexcept:
d1_(), lc_flags_( 0 )
{
#ifndef BOOST_NO_RTTI
if( detail::std_category const* pc2 = dynamic_cast< detail::std_category const* >( &ec.category() ) )
{
*this = boost::system::error_code( ec.value(), pc2->original_category() );
}
else
#endif
{
::new( d2_ ) std::error_code( ec );
lc_flags_ = 1;
}
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) noexcept
{
*this = error_code( val, cat );
}
void assign( int val, const error_category & cat, source_location const * loc ) noexcept
{
*this = error_code( val, cat, loc );
}
void assign( error_code const& ec, source_location const * loc ) noexcept
{
*this = error_code( ec, loc );
}
template<typename ErrorCodeEnum>
BOOST_SYSTEM_CONSTEXPR typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code>::type &
operator=( ErrorCodeEnum val ) noexcept
{
*this = make_error_code( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() noexcept
{
*this = error_code();
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const noexcept
{
if( lc_flags_ != 1 )
{
return d1_.val_;
}
else
{
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
unsigned cv = static_cast<unsigned>( ec.value() );
unsigned ch = static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
return static_cast<int>( cv + 1000 * ch );
}
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const noexcept
{
if( lc_flags_ == 0 )
{
return system_category();
}
else if( lc_flags_ == 1 )
{
return detail::interop_category();
}
else
{
return *d1_.cat_;
}
}
// deprecated?
error_condition default_error_condition() const noexcept
{
return category().default_error_condition( value() );
}
std::string message() const
{
if( lc_flags_ == 1 )
{
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
return ec.message();
}
else if( lc_flags_ == 0 )
{
return detail::system_error_category_message( value() );
}
else
{
return category().message( value() );
}
}
char const * message( char * buffer, std::size_t len ) const noexcept
{
if( lc_flags_ == 1 )
{
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
#if !defined(BOOST_NO_EXCEPTIONS)
try
#endif
{
detail::snprintf( buffer, len, "%s", ec.message().c_str() );
return buffer;
}
#if !defined(BOOST_NO_EXCEPTIONS)
catch( ... )
{
detail::snprintf( buffer, len, "No message text available for error std:%s:%d", ec.category().name(), ec.value() );
return buffer;
}
#endif
}
else if( lc_flags_ == 0 )
{
return detail::system_error_category_message( value(), buffer, len );
}
else
{
return category().message( value(), buffer, len );
}
}
BOOST_SYSTEM_CONSTEXPR bool failed() const noexcept
{
if( lc_flags_ & 1 )
{
if( lc_flags_ == 1 )
{
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
return ec.value() != 0;
}
return true;
}
else
{
return false;
}
}
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const noexcept // true if error
{
return failed();
}
bool has_location() const noexcept
{
return lc_flags_ >= 4;
}
source_location const & location() const noexcept
{
BOOST_STATIC_CONSTEXPR source_location loc;
return lc_flags_ >= 4? *reinterpret_cast<source_location const*>( lc_flags_ &~ static_cast<boost::uintptr_t>( 1 ) ): loc;
}
// relationals:
private:
// private equality for use in error_category::equivalent
friend class error_category;
BOOST_SYSTEM_CONSTEXPR bool equals( int val, error_category const& cat ) const noexcept
{
if( lc_flags_ == 0 )
{
return val == 0 && cat.id_ == detail::system_category_id;
}
else if( lc_flags_ == 1 )
{
return cat.id_ == detail::interop_category_id && val == value();
}
else
{
return val == d1_.val_ && cat == *d1_.cat_;
}
}
public:
// the more symmetrical non-member syntax allows enum
// conversions work for both rhs and lhs.
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( const error_code & lhs, const error_code & rhs ) noexcept
{
bool s1 = lhs.lc_flags_ == 1;
bool s2 = rhs.lc_flags_ == 1;
if( s1 != s2 ) return false;
if( s1 && s2 )
{
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
return e1 == e2;
}
else
{
return lhs.value() == rhs.value() && lhs.category() == rhs.category();
}
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_code & lhs, const error_code & rhs ) noexcept
{
bool s1 = lhs.lc_flags_ == 1;
bool s2 = rhs.lc_flags_ == 1;
if( s1 < s2 ) return true;
if( s2 < s1 ) return false;
if( s1 && s2 )
{
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
return e1 < e2;
}
else
{
return lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value());
}
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept
{
return !( lhs == rhs );
}
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) noexcept
{
return lhs == static_cast< std::error_code >( rhs );
}
inline friend bool operator==( error_code const & lhs, std::error_code const & rhs ) noexcept
{
return static_cast< std::error_code >( lhs ) == rhs;
}
inline friend bool operator!=( std::error_code const & lhs, error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
inline friend bool operator!=( error_code const & lhs, std::error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
//
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
inline friend bool operator==( error_code const & lhs, E rhs ) noexcept
{
return lhs == make_error_condition( rhs );
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
inline friend bool operator==( E lhs, error_code const & rhs ) noexcept
{
return make_error_condition( lhs ) == rhs;
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
inline friend bool operator!=( error_code const & lhs, E rhs ) noexcept
{
return !( lhs == rhs );
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
inline friend bool operator!=( E lhs, error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
//
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_code const & lhs, E rhs ) noexcept
{
return lhs == make_error_code( rhs );
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_code const & rhs ) noexcept
{
return make_error_code( lhs ) == rhs;
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_code const & lhs, E rhs ) noexcept
{
return !( lhs == rhs );
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
#if defined(BOOST_SYSTEM_CLANG_6)
inline friend bool operator==( error_code const & lhs, std::error_condition const & rhs ) noexcept
{
return static_cast< std::error_code >( lhs ) == rhs;
}
inline friend bool operator==( std::error_condition const & lhs, error_code const & rhs ) noexcept
{
return lhs == static_cast< std::error_code >( rhs );
}
inline friend bool operator!=( error_code const & lhs, std::error_condition const & rhs ) noexcept
{
return !( lhs == rhs );
}
inline friend bool operator!=( std::error_condition const & lhs, error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
#endif
// conversions
operator std::error_code () const
{
if( lc_flags_ == 1 )
{
return *reinterpret_cast<std::error_code const*>( d2_ );
}
else if( lc_flags_ == 0 )
{
// This condition must be the same as the one in error_category_impl.hpp
#if defined(BOOST_SYSTEM_AVOID_STD_SYSTEM_CATEGORY)
return std::error_code( 0, boost::system::system_category() );
#else
return std::error_code();
#endif
}
else
{
return std::error_code( d1_.val_, *d1_.cat_ );
}
}
operator std::error_code ()
{
return const_cast<error_code const&>( *this );
}
template<class T,
class E = typename detail::enable_if<detail::is_same<T, std::error_code>::value>::type>
operator T& ()
{
if( lc_flags_ != 1 )
{
std::error_code e2( *this );
::new( d2_ ) std::error_code( e2 );
lc_flags_ = 1;
}
return *reinterpret_cast<std::error_code*>( d2_ );
}
#if defined(BOOST_SYSTEM_CLANG_6)
template<class T,
class E = typename std::enable_if<std::is_same<T, std::error_code>::value>::type>
operator T const& () = delete;
#endif
std::string to_string() const
{
if( lc_flags_ == 1 )
{
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( d2_ );
std::string r( "std:" );
r += e2.category().name();
detail::append_int( r, e2.value() );
return r;
}
else
{
std::string r = category_name();
detail::append_int( r, value() );
return r;
}
}
template<class Ch, class Tr>
inline friend std::basic_ostream<Ch, Tr>&
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
{
return os << ec.to_string().c_str();
}
std::string what() const
{
std::string r = message();
r += " [";
r += to_string();
if( has_location() )
{
r += " at ";
r += location().to_string();
}
r += "]";
return r;
}
};
inline bool operator==( const error_code & code, const error_condition & condition ) noexcept
{
if( code.lc_flags_ == 1 )
{
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
}
else
{
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
}
}
inline bool operator==( const error_condition & condition, const error_code & code ) noexcept
{
return code == condition;
}
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) noexcept
{
return !( lhs == rhs );
}
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) noexcept
{
return !( lhs == rhs );
}
inline std::size_t hash_value( error_code const & ec )
{
if( ec.lc_flags_ == 1 )
{
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( ec.d2_ );
return std::hash<std::error_code>()( e2 );
}
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
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
# pragma GCC diagnostic pop
#endif
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERROR_CODE_HPP_INCLUDED

View File

@ -0,0 +1,326 @@
#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-2021
//
// 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/detail/is_same.hpp>
#include <boost/system/detail/errc.hpp>
#include <boost/system/detail/append_int.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
namespace detail
{
struct generic_value_tag
{
int value;
BOOST_SYSTEM_CONSTEXPR explicit generic_value_tag( int v ): value( v ) {}
};
} // namespace detail
class error_condition
{
private:
int val_;
error_category const * cat_;
private:
boost::ulong_long_type cat_id() const noexcept
{
return cat_? cat_->id_: detail::generic_category_id;
}
public:
// constructors:
BOOST_SYSTEM_CONSTEXPR error_condition() noexcept:
val_( 0 ), cat_( 0 )
{
}
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) noexcept:
val_( val ), cat_( &cat )
{
}
BOOST_SYSTEM_CONSTEXPR explicit error_condition( boost::system::detail::generic_value_tag vt ) noexcept:
val_( vt.value ), cat_( 0 )
{
}
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
typename detail::enable_if<
is_error_condition_enum<ErrorConditionEnum>::value && !boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value
>::type* = 0) noexcept
{
*this = make_error_condition( e );
}
template<class ErrorConditionEnum> BOOST_SYSTEM_CONSTEXPR error_condition( ErrorConditionEnum e,
typename detail::enable_if<boost::system::detail::is_same<ErrorConditionEnum, errc::errc_t>::value>::type* = 0) noexcept:
val_( e ), cat_( 0 )
{
}
// modifiers:
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) 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 ) noexcept
{
*this = error_condition( val );
return *this;
}
BOOST_SYSTEM_CONSTEXPR void clear() noexcept
{
val_ = 0;
cat_ = 0;
}
// observers:
BOOST_SYSTEM_CONSTEXPR int value() const noexcept
{
return val_;
}
BOOST_SYSTEM_CONSTEXPR const error_category & category() const noexcept
{
return cat_? *cat_: generic_category();
}
std::string message() const
{
if( cat_ )
{
return cat_->message( value() );
}
else
{
return detail::generic_error_category_message( value() );
}
}
char const * message( char * buffer, std::size_t len ) const noexcept
{
if( cat_ )
{
return cat_->message( value(), buffer, len );
}
else
{
return detail::generic_error_category_message( value(), buffer, len );
}
}
BOOST_SYSTEM_CONSTEXPR bool failed() const noexcept
{
if( cat_ )
{
return detail::failed_impl( val_, *cat_ );
}
else
{
return val_ != 0;
}
}
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const noexcept // true if error
{
return failed();
}
// 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 ) noexcept
{
if( lhs.val_ != rhs.val_ )
{
return false;
}
else if( lhs.cat_ == 0 )
{
return rhs.cat_id() == detail::generic_category_id;
}
else if( rhs.cat_ == 0 )
{
return lhs.cat_id() == detail::generic_category_id;
}
else
{
return *lhs.cat_ == *rhs.cat_;
}
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept
{
error_category const& lcat = lhs.category();
error_category const& rcat = rhs.category();
return lcat < rcat || ( lcat == rcat && lhs.val_ < rhs.val_ );
}
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept
{
return !( lhs == rhs );
}
operator std::error_condition () const
{
// This condition must be the same as the one in error_category_impl.hpp
#if defined(BOOST_SYSTEM_AVOID_STD_GENERIC_CATEGORY)
return std::error_condition( value(), category() );
#else
if( cat_ )
{
return std::error_condition( val_, *cat_ );
}
else
{
return std::error_condition( val_, std::generic_category() );
}
#endif
}
inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) noexcept
{
return lhs == static_cast< std::error_condition >( rhs );
}
inline friend bool operator==( error_condition const & lhs, std::error_code const & rhs ) noexcept
{
return static_cast< std::error_condition >( lhs ) == rhs;
}
inline friend bool operator!=( std::error_code const & lhs, error_condition const & rhs ) noexcept
{
return !( lhs == rhs );
}
inline friend bool operator!=( error_condition const & lhs, std::error_code const & rhs ) noexcept
{
return !( lhs == rhs );
}
//
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_condition const & lhs, E rhs ) noexcept
{
return lhs == make_error_condition( rhs );
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_condition const & rhs ) noexcept
{
return make_error_condition( lhs ) == rhs;
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_condition const & lhs, E rhs ) noexcept
{
return !( lhs == rhs );
}
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_condition const & rhs ) noexcept
{
return !( lhs == rhs );
}
//
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
inline friend bool operator==( error_condition const & lhs, E rhs ) noexcept
{
return lhs == make_error_code( rhs );
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
inline friend bool operator==( E lhs, error_condition const & rhs ) noexcept
{
return make_error_code( lhs ) == rhs;
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
inline friend bool operator!=( error_condition const & lhs, E rhs ) noexcept
{
return !( lhs == rhs );
}
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
inline friend bool operator!=( E lhs, error_condition const & rhs ) noexcept
{
return !( lhs == rhs );
}
std::string to_string() const
{
std::string r( "cond:" );
if( cat_ )
{
r += cat_->name();
}
else
{
r += "generic";
}
detail::append_int( r, value() );
return r;
}
template<class Ch, class Tr>
inline friend std::basic_ostream<Ch, Tr>&
operator<< (std::basic_ostream<Ch, Tr>& os, error_condition const & en)
{
os << en.to_string();
return os;
}
};
} // 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() noexcept:
error_category( detail::generic_category_id )
{
return buffer;
}
if( len == 1 )
const char * name() const 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 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 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() 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() noexcept BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & generic_category() 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,120 @@
#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 * ) noexcept
{
return r;
}
inline char const * strerror_r_helper( int r, char const * buffer ) noexcept
{
return r == 0? buffer: "Unknown error";
}
inline char const * generic_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
{
if( buffer != nullptr )
{
return strerror_r_helper( strerror_r( ev, buffer, len ), buffer );
}
else
{
// strerror_r requires non-null buffer pointer
char tmp[ 1 ] = {};
char const* r = strerror_r_helper( strerror_r( ev, tmp, 0 ), buffer );
return r == tmp? nullptr: r;
}
}
inline std::string generic_error_category_message( int ev )
{
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 ) 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

@ -0,0 +1,107 @@
#ifndef BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED
// Copyright Beman Dawes 2006, 2007
// Copyright Christoper Kohlhoff 2007
// Copyright Peter Dimov 2017, 2018, 2021
//
// 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/snprintf.hpp>
#include <boost/system/detail/config.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace system
{
namespace detail
{
// interop_error_category, used for std::error_code
#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 interop_error_category: public error_category
{
public:
BOOST_SYSTEM_CONSTEXPR interop_error_category() noexcept:
error_category( detail::interop_category_id )
{
}
const char * name() const noexcept BOOST_OVERRIDE
{
return "std:unknown";
}
std::string message( int ev ) const BOOST_OVERRIDE;
char const * message( int ev, char * buffer, std::size_t len ) const noexcept BOOST_OVERRIDE;
};
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic pop
#endif
inline char const * interop_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
{
detail::snprintf( buffer, len, "Unknown interop error %d", ev );
return buffer;
}
inline std::string interop_error_category::message( int ev ) const
{
char buffer[ 48 ];
return message( ev, buffer, sizeof( buffer ) );
}
// interop_category()
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
template<class T> struct BOOST_SYMBOL_VISIBLE interop_cat_holder
{
static constexpr interop_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 interop_error_category interop_cat_holder<T>::instance;
#endif
constexpr error_category const & interop_category() noexcept
{
return interop_cat_holder<void>::instance;
}
#else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
#if !defined(__SUNPRO_CC) // trailing __global is not supported
inline error_category const & interop_category() noexcept BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & interop_category() noexcept
{
static const detail::interop_error_category instance;
return instance;
}
#endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_INTEROP_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,23 @@
#ifndef BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED
// Copyright 2021 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// http://www.boost.org/LICENSE_1_0.txt
#include <type_traits>
namespace boost
{
namespace system
{
namespace detail
{
using std::is_same;
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_IS_SAME_HPP_INCLUDED

View File

@ -0,0 +1,128 @@
#ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#if defined(BOOST_SYSTEM_DISABLE_THREADS)
namespace boost
{
namespace system
{
namespace detail
{
struct mutex
{
void lock()
{
}
void unlock()
{
}
};
} // namespace detail
} // namespace system
} // namespace boost
#else // defined(BOOST_SYSTEM_DISABLE_THREADS)
#if defined(BOOST_MSSTL_VERSION) && BOOST_MSSTL_VERSION >= 140
// Under the MS STL, std::mutex::mutex() is not constexpr, as is
// required by the standard, which leads to initialization order
// issues. However, shared_mutex is based on SRWLock and its
// default constructor is constexpr, so we use that instead.
#include <boost/winapi/config.hpp>
// SRWLOCK is not available when targeting Windows XP
#if BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
#include <shared_mutex>
#if BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
# define BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX
#endif
#endif // BOOST_MSSTL_VERSION >= 142 || _HAS_SHARED_MUTEX
#endif // BOOST_USE_WINAPI_VERSION >= BOOST_WINAPI_VERSION_WIN6
#if defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
namespace boost
{
namespace system
{
namespace detail
{
typedef std::shared_mutex mutex;
} // namespace detail
} // namespace system
} // namespace boost
#else // defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
#include <mutex>
namespace boost
{
namespace system
{
namespace detail
{
using std::mutex;
} // namespace detail
} // namespace system
} // namespace boost
#endif // defined(BOOST_SYSTEM_HAS_MSSTL_SHARED_MUTEX)
#endif // defined(BOOST_SYSTEM_DISABLE_THREADS)
namespace boost
{
namespace system
{
namespace detail
{
template<class Mtx> class lock_guard
{
private:
Mtx& mtx_;
private:
lock_guard( lock_guard const& );
lock_guard& operator=( lock_guard const& );
public:
explicit lock_guard( Mtx& mtx ): mtx_( mtx )
{
mtx_.lock();
}
~lock_guard()
{
mtx_.unlock();
}
};
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_MUTEX_HPP_INCLUDED

View File

@ -0,0 +1,28 @@
#ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
// Copyright 2018, 2020, 2021 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <cstdio>
//
namespace boost
{
namespace system
{
namespace detail
{
using std::snprintf;
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED

View File

@ -0,0 +1,84 @@
#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
// Support for interoperability between Boost.System and <system_error>
//
// Copyright 2018, 2021 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/error_category.hpp>
#include <boost/config.hpp>
#include <system_error>
//
namespace boost
{
namespace system
{
namespace detail
{
template<unsigned Id> struct id_wrapper {};
class BOOST_SYMBOL_VISIBLE std_category: public std::error_category
{
private:
boost::system::error_category const * pc_;
public:
boost::system::error_category const & original_category() const noexcept
{
return *pc_;
}
public:
template<unsigned Id>
explicit std_category( boost::system::error_category const * pc, id_wrapper<Id> ): pc_( pc )
{
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
// We used to assign to the protected _Addr member of std::error_category
// here when Id != 0, but this should never happen now because this code
// path is no longer used
static_assert( Id == 0, "This constructor should only be called with Id == 0 under MS STL 14.0+" );
#endif
}
const char * name() const noexcept BOOST_OVERRIDE
{
return pc_->name();
}
std::string message( int ev ) const BOOST_OVERRIDE
{
return pc_->message( ev );
}
std::error_condition default_error_condition( int ev ) const noexcept BOOST_OVERRIDE
{
return pc_->default_error_condition( ev );
}
inline bool equivalent( int code, const std::error_condition & condition ) const noexcept BOOST_OVERRIDE;
inline bool equivalent( const std::error_code & code, int condition ) const noexcept BOOST_OVERRIDE;
};
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED

View File

@ -0,0 +1,97 @@
#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED
// Support for interoperability between Boost.System and <system_error>
//
// Copyright 2018, 2021 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// See library home page at http://www.boost.org/libs/system
#include <boost/system/detail/std_category.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/detail/generic_category.hpp>
//
namespace boost
{
namespace system
{
namespace detail
{
inline bool std_category::equivalent( int code, const std::error_condition & condition ) const noexcept
{
if( condition.category() == *this )
{
boost::system::error_condition bn( condition.value(), *pc_ );
return pc_->equivalent( code, bn );
}
else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() )
{
boost::system::error_condition bn( condition.value(), boost::system::generic_category() );
return pc_->equivalent( code, bn );
}
#ifndef BOOST_NO_RTTI
else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) )
{
boost::system::error_condition bn( condition.value(), *pc2->pc_ );
return pc_->equivalent( code, bn );
}
#endif
else
{
return default_error_condition( code ) == condition;
}
}
inline bool std_category::equivalent( const std::error_code & code, int condition ) const noexcept
{
if( code.category() == *this )
{
boost::system::error_code bc( code.value(), *pc_ );
return pc_->equivalent( bc, condition );
}
else if( code.category() == std::generic_category() || code.category() == boost::system::generic_category() )
{
boost::system::error_code bc( code.value(), boost::system::generic_category() );
return pc_->equivalent( bc, condition );
}
#ifndef BOOST_NO_RTTI
else if( std_category const* pc2 = dynamic_cast< std_category const* >( &code.category() ) )
{
boost::system::error_code bc( code.value(), *pc2->pc_ );
return pc_->equivalent( bc, condition );
}
#endif
else if( *pc_ == boost::system::generic_category() )
{
return std::generic_category().equivalent( code, condition );
}
else
{
return false;
}
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED

View File

@ -1,180 +0,0 @@
// Support for interoperability between Boost.System and <system_error>
//
// 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 <system_error>
#include <map>
#include <memory>
#include <mutex>
//
namespace boost
{
namespace system
{
namespace detail
{
class BOOST_SYMBOL_VISIBLE std_category: public std::error_category
{
private:
boost::system::error_category const * pc_;
public:
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
{
return pc_->name();
}
virtual std::string message( int ev ) const
{
return pc_->message( ev );
}
virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT
{
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;
};
inline std::error_category const & to_std_category( boost::system::error_category const & cat ) BOOST_SYMBOL_VISIBLE;
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 )
{
if( cat == boost::system::system_category() )
{
static const std_category system_instance( &cat, 0x1F4D7 );
return system_instance;
}
else if( cat == boost::system::generic_category() )
{
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;
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
{
if( condition.category() == *this )
{
boost::system::error_condition bn( condition.value(), *pc_ );
return pc_->equivalent( code, bn );
}
else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() )
{
boost::system::error_condition bn( condition.value(), boost::system::generic_category() );
return pc_->equivalent( code, bn );
}
#ifndef BOOST_NO_RTTI
else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) )
{
boost::system::error_condition bn( condition.value(), *pc2->pc_ );
return pc_->equivalent( code, bn );
}
#endif
else
{
return default_error_condition( code ) == condition;
}
}
inline bool std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT
{
if( code.category() == *this )
{
boost::system::error_code bc( code.value(), *pc_ );
return pc_->equivalent( bc, condition );
}
else if( code.category() == std::generic_category() || code.category() == boost::system::generic_category() )
{
boost::system::error_code bc( code.value(), boost::system::generic_category() );
return pc_->equivalent( bc, condition );
}
#ifndef BOOST_NO_RTTI
else if( std_category const* pc2 = dynamic_cast< std_category const* >( &code.category() ) )
{
boost::system::error_code bc( code.value(), *pc2->pc_ );
return pc_->equivalent( bc, condition );
}
#endif
else if( *pc_ == boost::system::generic_category() )
{
return std::generic_category().equivalent( code, condition );
}
else
{
return false;
}
}
} // namespace detail
} // namespace system
} // namespace boost

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() noexcept:
error_category( detail::system_category_id )
{
}
const char * name() const noexcept BOOST_OVERRIDE
{
return "system";
}
error_condition default_error_condition( int ev ) const noexcept BOOST_OVERRIDE;
std::string message( int ev ) const BOOST_OVERRIDE;
char const * message( int ev, char * buffer, std::size_t len ) const 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() 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() noexcept BOOST_SYMBOL_VISIBLE;
#endif
inline error_category const & system_category() 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,157 @@
#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 ) 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_NETPATH_: return no_such_file_or_directory;
case ERROR_BAD_NET_NAME_: return no_such_file_or_directory;
case ERROR_BAD_UNIT_: return no_such_device;
case ERROR_BROKEN_PIPE_: return broken_pipe;
case ERROR_BUFFER_OVERFLOW_: return filename_too_long;
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_FILENAME_EXCED_RANGE_: return filename_too_long;
case ERROR_FILE_EXISTS_: return file_exists;
case ERROR_FILE_NOT_FOUND_: return no_such_file_or_directory;
case ERROR_HANDLE_DISK_FULL_: return no_space_on_device;
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 no_such_file_or_directory;
case ERROR_INVALID_PARAMETER_: 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_REPARSE_TAG_INVALID_: return invalid_argument;
case ERROR_RETRY_: return resource_unavailable_try_again;
case ERROR_SEEK_: return io_error;
case ERROR_SEM_TIMEOUT_: return timed_out;
case ERROR_SHARING_VIOLATION_: return permission_denied;
case ERROR_NOT_SUPPORTED_: return not_supported; // WinError.h: "The request is not supported."
case ERROR_TIMEOUT_: return timed_out;
case ERROR_TOO_MANY_OPEN_FILES_: return too_many_files_open;
case ERROR_WRITE_FAULT_: return io_error;
case ERROR_WRITE_PROTECT_: return permission_denied;
case 258: return timed_out; // WAIT_TIMEOUT
case WSAEACCES_: return permission_denied;
case WSAEADDRINUSE_: return address_in_use;
case WSAEADDRNOTAVAIL_: return address_not_available;
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,61 @@
#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/system_category_message.hpp>
#include <boost/system/detail/error_condition.hpp>
#include <boost/system/api_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_condition_win32.hpp>
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
{
int e2 = system_category_condition_win32( ev );
if( e2 == -1 )
{
return error_condition( ev, *this );
}
else
{
return error_condition( boost::system::detail::generic_value_tag( e2 ) );
}
}
#else // #if defined(BOOST_WINDOWS_API)
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
{
return error_condition( boost::system::detail::generic_value_tag( ev ) );
}
#endif // #if defined(BOOST_WINDOWS_API)
inline std::string boost::system::detail::system_error_category::message( int ev ) const
{
return system_error_category_message( ev );
}
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
{
return system_error_category_message( ev, buffer, len );
}
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED

View File

@ -0,0 +1,71 @@
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
// Implementation of system_error_category_message
//
// Copyright 2018, 2022 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/api_config.hpp>
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
#endif
#if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/system_category_message_win32.hpp>
namespace boost
{
namespace system
{
namespace detail
{
inline std::string system_error_category_message( int ev )
{
return system_category_message_win32( ev );
}
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
{
return system_category_message_win32( ev, buffer, len );
}
} // namespace detail
} // namespace system
} // namespace boost
#else // #if defined(BOOST_WINDOWS_API)
#include <boost/system/detail/generic_category_message.hpp>
namespace boost
{
namespace system
{
namespace detail
{
inline std::string system_error_category_message( int ev )
{
return generic_error_category_message( ev );
}
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) noexcept
{
return generic_error_category_message( ev, buffer, len );
}
} // namespace detail
} // namespace system
} // namespace boost
#endif // #if defined(BOOST_WINDOWS_API)
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED

View File

@ -0,0 +1,211 @@
#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/system/detail/snprintf.hpp>
#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
{
inline char const * unknown_message_win32( int ev, char * buffer, std::size_t len )
{
detail::snprintf( buffer, len, "Unknown error (%d)", ev );
return buffer;
}
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 ) 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,
static_cast<DWORD_>(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,
static_cast<DWORD_>(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,
static_cast<DWORD_>(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( static_cast<std::size_t>(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[ static_cast<std::size_t>(r)-1 ] == '\n' || buffer[ static_cast<std::size_t>(r)-1 ] == '\r' ) )
{
--r;
}
if( r > 0 && buffer[ static_cast<std::size_t>(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,132 +0,0 @@
// POSIX-specific implementation details of system_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
namespace boost
{
namespace system
{
namespace detail
{
inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
{
using namespace errc;
static int const gen[] =
{
success,
address_family_not_supported,
address_in_use,
address_not_available,
already_connected,
argument_list_too_long,
argument_out_of_domain,
bad_address,
bad_file_descriptor,
bad_message,
broken_pipe,
connection_aborted,
connection_already_in_progress,
connection_refused,
connection_reset,
cross_device_link,
destination_address_required,
device_or_resource_busy,
directory_not_empty,
executable_format_error,
file_exists,
file_too_large,
filename_too_long,
function_not_supported,
host_unreachable,
identifier_removed,
illegal_byte_sequence,
inappropriate_io_control_operation,
interrupted,
invalid_argument,
invalid_seek,
io_error,
is_a_directory,
message_size,
network_down,
network_reset,
network_unreachable,
no_buffer_space,
no_child_process,
no_link,
no_lock_available,
no_message_available,
no_message,
no_protocol_option,
no_space_on_device,
no_stream_resources,
no_such_device_or_address,
no_such_device,
no_such_file_or_directory,
no_such_process,
not_a_directory,
not_a_socket,
not_a_stream,
not_connected,
not_enough_memory,
not_supported,
operation_canceled,
operation_in_progress,
operation_not_permitted,
operation_not_supported,
operation_would_block,
owner_dead,
permission_denied,
protocol_error,
protocol_not_supported,
read_only_file_system,
resource_deadlock_would_occur,
resource_unavailable_try_again,
result_out_of_range,
state_not_recoverable,
stream_timeout,
text_file_busy,
timed_out,
too_many_files_open_in_system,
too_many_files_open,
too_many_links,
too_many_symbolic_link_levels,
value_too_large,
wrong_protocol_type
};
int const n = sizeof( gen ) / sizeof( gen[0] );
for( int i = 0; i < n; ++i )
{
if( ev == gen[ i ] ) return true;
}
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

View File

@ -1,341 +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;
}
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;
}
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_CONNECTION_ABORTED_: return make_error_condition( connection_aborted );
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

@ -0,0 +1,57 @@
#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/assert/source_location.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 ) noexcept
{
return error_code( e, generic_category() );
}
// explicit conversion:
inline error_code make_error_code( errc_t e, boost::source_location const * loc ) noexcept
{
return error_code( e, generic_category(), loc );
}
// implicit conversion:
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) 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,959 +10,12 @@
//
// 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/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
{
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
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
#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
#if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
#pragma GCC diagnostic pop
#endif
// generic_category(), system_category()
#if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
namespace detail
{
template<class T> struct BOOST_SYMBOL_VISIBLE cat_holder
{
static constexpr system_error_category system_category_instance{};
static constexpr generic_error_category generic_category_instance{};
};
template<class T> constexpr system_error_category cat_holder<T>::system_category_instance;
template<class T> 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 BOOST_SYMBOL_VISIBLE;
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 BOOST_SYMBOL_VISIBLE;
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 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
};
// 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 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_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() );
}
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
{
return !( lhs == rhs );
}
inline bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
{
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
}
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
{
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::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 );
}
// 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)
#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>
#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

File diff suppressed because it is too large Load Diff

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

@ -1,84 +1,55 @@
// Boost system_error.hpp --------------------------------------------------//
// Copyright Beman Dawes 2006
// 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)
#ifndef BOOST_SYSTEM_SYSTEM_ERROR_HPP
#define BOOST_SYSTEM_SYSTEM_ERROR_HPP
#include <boost/system/error_code.hpp>
// Copyright Beman Dawes 2006
// Copyright Peter Dimov 2021
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/errc.hpp>
#include <boost/system/detail/error_code.hpp>
#include <string>
#include <stdexcept>
#include <cassert>
namespace boost
{
namespace system
{
// class system_error ------------------------------------------------------------//
namespace system
{
class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error
// BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared
// library can be caught. See svn.boost.org/trac/boost/ticket/3697
class BOOST_SYMBOL_VISIBLE system_error: public std::runtime_error
{
private:
error_code code_;
public:
explicit system_error( error_code const & ec ):
std::runtime_error( ec.what() ), code_( ec ) {}
system_error( error_code const & ec, std::string const & prefix ):
std::runtime_error( prefix + ": " + ec.what() ), code_( ec ) {}
system_error( error_code const & ec, char const * prefix ):
std::runtime_error( std::string( prefix ) + ": " + ec.what() ), code_( ec ) {}
system_error( int ev, error_category const & ecat ):
std::runtime_error( error_code( ev, ecat ).what() ), code_( ev, ecat ) {}
system_error( int ev, error_category const & ecat, std::string const & prefix ):
std::runtime_error( prefix + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {}
system_error( int ev, error_category const & ecat, char const * prefix ):
std::runtime_error( std::string( prefix ) + ": " + error_code( ev, ecat ).what() ), code_( ev, ecat ) {}
error_code code() const noexcept
{
public:
explicit system_error( error_code ec )
: std::runtime_error(""), m_error_code(ec) {}
system_error( error_code ec, const std::string & what_arg )
: std::runtime_error(what_arg), m_error_code(ec) {}
system_error( error_code ec, const char* what_arg )
: std::runtime_error(what_arg), m_error_code(ec) {}
system_error( int ev, const error_category & ecat )
: std::runtime_error(""), m_error_code(ev,ecat) {}
system_error( int ev, const error_category & ecat,
const std::string & what_arg )
: std::runtime_error(what_arg), m_error_code(ev,ecat) {}
system_error( int ev, const error_category & ecat,
const char * what_arg )
: std::runtime_error(what_arg), m_error_code(ev,ecat) {}
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;
private:
error_code m_error_code;
mutable std::string m_what;
};
// implementation ------------------------------------------------------//
inline const char * system_error::what() const BOOST_NOEXCEPT_OR_NOTHROW
// see http://www.boost.org/more/error_handling.html for lazy build rationale
{
if ( m_what.empty() )
{
#ifndef BOOST_NO_EXCEPTIONS
try
#endif
{
m_what = this->std::runtime_error::what();
if ( !m_what.empty() ) m_what += ": ";
m_what += m_error_code.message();
}
#ifndef BOOST_NO_EXCEPTIONS
catch (...) { return std::runtime_error::what(); }
#endif
}
return m_what.c_str();
return code_;
}
};
} // namespace system
} // namespace system
} // namespace boost
#endif // BOOST_SYSTEM_SYSTEM_ERROR_HPP

View File

@ -18,16 +18,6 @@
#ifdef BOOST_WINDOWS_API
#include <boost/system/error_code.hpp>
//// Neither MinGW or Cygwin versions of winerror.h work if used alone, so on
//// either of those platforms include the full windows.h
//
//#if defined(__MINGW32__) || defined(__CYGWIN__)
//#include <windows.h>
//#else
//#include <winerror.h>
//#endif
#include <boost/winapi/error_codes.hpp>
namespace boost
@ -82,7 +72,8 @@ namespace boost
wrong_disk = boost::winapi::ERROR_WRONG_DISK_,
sharing_buffer_exceeded = boost::winapi::ERROR_SHARING_BUFFER_EXCEEDED_,
handle_eof = boost::winapi::ERROR_HANDLE_EOF_,
handle_disk_full= boost::winapi::ERROR_HANDLE_DISK_FULL_,
handle_disk_full = boost::winapi::ERROR_HANDLE_DISK_FULL_,
not_supported = boost::winapi::ERROR_NOT_SUPPORTED_,
rem_not_list = boost::winapi::ERROR_REM_NOT_LIST_,
dup_name = boost::winapi::ERROR_DUP_NAME_,
bad_net_path = boost::winapi::ERROR_BAD_NETPATH_,
@ -94,7 +85,7 @@ namespace boost
broken_pipe = boost::winapi::ERROR_BROKEN_PIPE_,
open_failed = boost::winapi::ERROR_OPEN_FAILED_,
buffer_overflow = boost::winapi::ERROR_BUFFER_OVERFLOW_,
disk_full= boost::winapi::ERROR_DISK_FULL_,
disk_full = boost::winapi::ERROR_DISK_FULL_,
// ...
lock_failed = boost::winapi::ERROR_LOCK_FAILED_,
busy = boost::winapi::ERROR_BUSY_,

View File

@ -8,8 +8,8 @@ Automatic redirection failed, please go to
</body>
</html>
<!--
<EFBFBD> Copyright Beman Dawes, 2001
© Copyright Beman Dawes, 2001
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
https://www.boost.org/LICENSE_1_0.txt
-->

View File

@ -4,8 +4,14 @@
"authors": [
"Beman Dawes"
],
"description": "Operating system support, including the diagnostics support that will be part of the C++0x standard library.",
"maintainers": [
"Peter Dimov <pdimov -at- gmail.com>"
],
"description": "Extensible error reporting.",
"category": [
"System"
]
"System",
"Error-handling",
"Programming"
],
"cxxstd": "11"
}

179
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,179 @@
# 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)
boost_test(SOURCES ${s1} ${ARGN} COMPILE_DEFINITIONS BOOST_SYSTEM_DISABLE_THREADS NAME ${n1}_nthr)
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)
boost_test(TYPE run SOURCES is_error_code_enum_test.cpp)
boost_test(TYPE run SOURCES is_error_condition_enum_test.cpp)
boost_test(TYPE run SOURCES errc_test.cpp)
boost_test(TYPE run SOURCES errc_test2.cpp)
boost_test(TYPE run SOURCES error_category_test2.cpp)
boost_test(TYPE run SOURCES error_condition_test.cpp)
boost_test(TYPE run SOURCES error_condition_test2.cpp)
boost_test(TYPE run SOURCES generic_category_test2.cpp)
boost_test(TYPE run SOURCES generic_category_test3.cpp)
boost_test(TYPE run SOURCES system_category_test2.cpp)
boost_test(TYPE run SOURCES system_category_test3.cpp)
boost_test(TYPE run SOURCES windows_error_test.cpp)
boost_test(TYPE run SOURCES linux_error_test.cpp)
boost_test(TYPE link SOURCES errc_test3.cpp)
boost_test(TYPE run SOURCES snprintf_test.cpp)
boost_test(TYPE run SOURCES std_interop_test2.cpp)
boost_test(TYPE run SOURCES std_interop_test3.cpp)
boost_test(TYPE run SOURCES std_interop_test4.cpp)
boost_test(TYPE run SOURCES std_interop_test5.cpp)
boost_test(TYPE run SOURCES std_interop_test6.cpp)
boost_test(TYPE run SOURCES std_interop_test7.cpp)
boost_test(TYPE run SOURCES std_interop_test8.cpp)
boost_test(TYPE run SOURCES std_interop_test9.cpp)
boost_test(TYPE run SOURCES ec_location_test.cpp)
boost_test(TYPE run SOURCES error_condition_test3.cpp)
boost_test(TYPE run SOURCES error_code_test2.cpp)
boost_test(TYPE run SOURCES system_error_test2.cpp)
boost_test(TYPE run SOURCES std_interop_test10.cpp)
boost_test(TYPE run SOURCES ec_location_test2.cpp)
boost_test(TYPE run SOURCES ec_what_test.cpp)
boost_test(TYPE run SOURCES system_error_test3.cpp)
boost_test(TYPE run SOURCES std_interop_test11.cpp)
boost_test(TYPE run SOURCES ec_wstream_test.cpp)
boost_test(TYPE run SOURCES std_interop_test12.cpp)
boost_test(TYPE run SOURCES errc_test4.cpp)
boost_test(TYPE run SOURCES std_interop_test13.cpp)
boost_test(TYPE run SOURCES std_interop_test14.cpp)
boost_test(TYPE run SOURCES ec_location_test3.cpp)
boost_test(TYPE run SOURCES ec_location_test4.cpp)
boost_test(TYPE compile SOURCES constexpr_test2.cpp)
boost_test(TYPE run SOURCES error_code_test3.cpp)
boost_test(TYPE run SOURCES std_interop_test15.cpp)
boost_test(TYPE run SOURCES win32_generic_test.cpp)
boost_test(TYPE run SOURCES ec_hash_value_test.cpp)
boost_test(TYPE run SOURCES std_interop_test16.cpp)
# result
boost_test(TYPE run SOURCES result_default_construct.cpp)
boost_test(TYPE run SOURCES result_value_construct.cpp)
boost_test(TYPE run SOURCES result_error_construct.cpp)
boost_test(TYPE run SOURCES result_copy_construct.cpp)
boost_test(TYPE run SOURCES result_move_construct.cpp)
boost_test(TYPE run SOURCES result_copy_assign.cpp)
boost_test(TYPE run SOURCES result_move_assign.cpp)
boost_test(TYPE run SOURCES result_value_access.cpp)
boost_test(TYPE run SOURCES result_error_access.cpp)
boost_test(TYPE run SOURCES result_swap.cpp)
boost_test(TYPE run SOURCES result_eq.cpp)
boost_test(TYPE run SOURCES result_range_for.cpp)
boost_test(TYPE run SOURCES result_value_construct2.cpp)
boost_test(TYPE run SOURCES result_error_construct2.cpp)
boost_test(TYPE run SOURCES result_errc_construct.cpp)
boost_test(TYPE run SOURCES result_convert_construct.cpp)
boost_test(TYPE run SOURCES result_typedefs.cpp)
boost_test(TYPE run SOURCES result_value_construct3.cpp)
boost_test(TYPE run SOURCES result_error_construct3.cpp)
boost_test(TYPE run SOURCES result_emplace.cpp)
boost_test(TYPE run SOURCES result_error_construct4.cpp)
boost_test(TYPE run SOURCES result_value_construct4.cpp)
boost_test(TYPE run SOURCES result_value_construct5.cpp)
boost_test(TYPE run SOURCES result_error_move.cpp)
boost_test(TYPE run SOURCES result_value_construct6.cpp)
boost_test(TYPE run SOURCES result_value_construct7.cpp)
boost_test(TYPE run SOURCES result_error_construct5.cpp)
boost_test(TYPE run SOURCES result_or_value.cpp)
boost_test(TYPE compile-fail SOURCES result_or_value_fail.cpp)
boost_test(TYPE compile-fail SOURCES result_or_value_fail2.cpp)
boost_test(TYPE run SOURCES result_or_fn0v.cpp)
boost_test(TYPE run SOURCES result_or_fn0r.cpp)
boost_test(TYPE run SOURCES result_and_fn1v.cpp)
boost_test(TYPE run SOURCES result_and_fn1r.cpp)
boost_test(TYPE run SOURCES result_and_eq_fn1v.cpp)
boost_test(TYPE run SOURCES result_and_eq_fn1r.cpp)
boost_test(TYPE run SOURCES result_in_place_use.cpp)
boost_test(TYPE run SOURCES result_or_eq_value.cpp)
boost_test(TYPE run SOURCES result_or_eq_fn0v.cpp)
boost_test(TYPE run SOURCES result_or_eq_fn0r.cpp)

View File

@ -1,7 +1,7 @@
# Boost System Library test Jamfile
# Copyright Beman Dawes 2003, 2006
# Copyright 2017-2019 Peter Dimov
# Copyright 2017-2021 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
@ -10,6 +10,23 @@
import testing ;
project
: default-build
<warnings>extra
: requirements
<library>/boost/system//boost_system
<library>/boost/core//boost_core
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<warnings-as-errors>on
<toolset>gcc-4.4:<cxxflags>-Wno-sign-compare
;
rule system-run ( sources + )
{
local result ;
@ -19,6 +36,7 @@ rule system-run ( sources + )
result += [ run $(sources) : : : <library>/boost/system//boost_system <link>shared : $(sources[1]:B)_shared ] ;
result += [ run $(sources) : : : <define>BOOST_NO_ANSI_APIS : $(sources[1]:B)_no_ansi ] ;
result += [ run $(sources) : : : <define>BOOST_SYSTEM_USE_UTF8 : $(sources[1]:B)_utf8 ] ;
result += [ run $(sources) : : : <define>BOOST_SYSTEM_DISABLE_THREADS : $(sources[1]:B)_nthr ] ;
return $(result) ;
}
@ -47,7 +65,11 @@ run single_instance_test.cpp single_instance_lib1 single_instance_lib2 : : : <li
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 ;
run-fail throws_assign_fail.cpp : : :
# GCC 12 catches this at compile time with a warning
<toolset>gcc,<variant>release:<build>no ;
system-run constexpr_test.cpp ;
system-run win32_hresult_test.cpp ;
@ -56,12 +78,18 @@ system-run generic_category_test.cpp ;
system-run system_category_test.cpp ;
system-run after_main_test.cpp ;
system-run failed_test.cpp ;
system-run failed_constexpr_test.cpp ;
run failed_constexpr_test.cpp : : :
# GCC w/ UBSAN doesn't consider `cat_ != 0` a constant expression
<toolset>gcc,<undefined-sanitizer>norecover:<build>no ;
# Quick (CI) test
run quick.cpp ;
run warnings_test.cpp : : : <warnings>all <warnings-as-errors>on <toolset>gcc:<cxxflags>-Wnon-virtual-dtor <toolset>clang:<cxxflags>-Wnon-virtual-dtor ;
run 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 ;
@ -69,3 +97,116 @@ lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>
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 linux_error_test.cpp ;
link errc_test3.cpp ;
run snprintf_test.cpp ;
run std_interop_test2.cpp ;
run std_interop_test3.cpp ;
run std_interop_test4.cpp ;
run std_interop_test5.cpp
: : :
# crash on xenial, but the real g++ 4.8 on both centos 7 and trusty works
<toolset>gcc-4.8:<build>no
<toolset>gcc-4.9:<build>no
;
run std_interop_test6.cpp ;
run std_interop_test7.cpp ;
run std_interop_test8.cpp ;
run std_interop_test9.cpp ;
run ec_location_test.cpp ;
run error_condition_test3.cpp ;
run error_code_test2.cpp ;
run system_error_test2.cpp ;
run std_interop_test10.cpp ;
run ec_location_test2.cpp ;
run ec_what_test.cpp ;
run system_error_test3.cpp ;
run std_interop_test11.cpp ;
run ec_wstream_test.cpp ;
run std_interop_test12.cpp ;
run errc_test4.cpp ;
run std_interop_test13.cpp ;
run std_interop_test14.cpp ;
run ec_location_test3.cpp ;
run ec_location_test4.cpp ;
compile constexpr_test2.cpp ;
run error_code_test3.cpp ;
run std_interop_test15.cpp ;
run win32_generic_test.cpp ;
run ec_hash_value_test.cpp ;
run std_interop_test16.cpp ;
# result
run result_default_construct.cpp ;
run result_value_construct.cpp ;
run result_error_construct.cpp ;
run result_copy_construct.cpp ;
run result_move_construct.cpp ;
run result_copy_assign.cpp ;
run result_move_assign.cpp ;
run result_value_access.cpp ;
run result_error_access.cpp ;
run result_swap.cpp : : : <toolset>gcc-10:<cxxflags>"-Wno-maybe-uninitialized" ;
run result_eq.cpp ;
run result_range_for.cpp ;
run result_value_construct2.cpp ;
run result_error_construct2.cpp ;
run result_errc_construct.cpp ;
run result_convert_construct.cpp ;
run result_typedefs.cpp ;
run result_value_construct3.cpp ;
run result_error_construct3.cpp ;
run result_emplace.cpp ;
run result_error_construct4.cpp ;
run result_value_construct4.cpp ;
run result_value_construct5.cpp ;
run result_error_move.cpp ;
run result_value_construct6.cpp ;
run result_value_construct7.cpp ;
run result_error_construct5.cpp ;
run result_or_value.cpp ;
compile-fail result_or_value_fail.cpp ;
compile-fail result_or_value_fail2.cpp ;
run result_or_fn0v.cpp ;
run result_or_fn0r.cpp ;
run result_and_fn1v.cpp ;
run result_and_fn1r.cpp ;
run result_and_eq_fn1v.cpp ;
run result_and_eq_fn1r.cpp ;
run result_in_place_use.cpp ;
run result_or_eq_value.cpp ;
run result_or_eq_fn0v.cpp ;
run result_or_eq_fn0r.cpp ;

View File

@ -5,8 +5,13 @@
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/quick_exit.hpp>
#include <boost/config.hpp>
#include <cerrno>
#if defined(BOOST_MSVC)
# pragma warning(disable: 4722) // Z::~Z never returns
#endif
using namespace boost::system;
struct Z
@ -27,4 +32,6 @@ static error_code e2( ENOENT, generic_category() );
int main()
{
(void)e1;
(void)e2;
}

View File

@ -0,0 +1,17 @@
# 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)
add_executable(main main.cpp)
target_link_libraries(main Boost::system)
enable_testing()
add_test(main main)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,44 @@
// Copyright 2017, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/system
#include <boost/system.hpp>
#include <cassert>
#include <cerrno>
#define BOOST_TEST(expr) assert(expr)
#define BOOST_TEST_EQ(x1, x2) assert((x1)==(x2))
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::error_code bc2 = make_error_code( boost::system::errc::no_such_file_or_directory );
BOOST_TEST_EQ( bc2, bc );
BOOST_TEST_EQ( bc2.value(), ev );
BOOST_TEST_EQ( &bc.category(), &bt );
boost::system::system_error x( bc, "prefix" );
BOOST_TEST_EQ( x.code(), bc );
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.what() );
}

View File

@ -1,8 +1,8 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2018-2021 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.5...3.20)
project(cmake_subdir_test LANGUAGES CXX)
@ -10,7 +10,11 @@ add_subdirectory(../.. boostorg/system)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../core boostorg/core)
add_subdirectory(../../../mp11 boostorg/mp11)
add_subdirectory(../../../predef boostorg/predef)
add_subdirectory(../../../static_assert boostorg/static_assert)
add_subdirectory(../../../throw_exception boostorg/throw_exception)
add_subdirectory(../../../variant2 boostorg/variant2)
add_subdirectory(../../../winapi boostorg/winapi)
add_executable(quick ../quick.cpp)
@ -19,4 +23,4 @@ target_link_libraries(quick Boost::system Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_custom_target(check VERBATIM COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure --no-tests=error -C $<CONFIG>)

View File

@ -50,16 +50,6 @@ int main()
std::cout << "BOOST_NO_ANSI_APIS is defined" << std::endl;
#else
std::cout << "BOOST_NO_ANSI_APIS is not defined" << std::endl;
#endif
#ifdef BOOST_NO_CXX11_NOEXCEPT
std::cout << "BOOST_NO_CXX11_NOEXCEPT is defined" << std::endl;
#else
std::cout << "BOOST_NO_CXX11_NOEXCEPT is not defined" << std::endl;
#endif
#ifdef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is defined" << std::endl;
#else
std::cout << "BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS is not defined" << std::endl;
#endif
return 0;
}

35
test/constexpr_test2.cpp Normal file
View File

@ -0,0 +1,35 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_GCC) && BOOST_GCC >= 40700 && BOOST_GCC < 40800
BOOST_PRAGMA_MESSAGE("Skipping test, BOOST_GCC is 407xx")
#else
struct X
{
boost::system::error_code ec;
};
X const& f()
{
#if defined(BOOST_CLANG_VERSION) && BOOST_CLANG_VERSION < 30900
BOOST_STATIC_CONSTEXPR X x = {};
return x;
#else
BOOST_STATIC_CONSTEXPR X x;
return x;
#endif
}
#endif

126
test/ec_hash_value_test.cpp Normal file
View File

@ -0,0 +1,126 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/system/system_category.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
#include <system_error>
namespace sys = boost::system;
int main()
{
// normal against normal (equal, system)
{
sys::error_code e2( 0, sys::system_category() );
sys::error_code e3( e2.value(), e2.category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal against normal (equal, generic)
{
sys::error_code e2( EINVAL, sys::generic_category() );
sys::error_code e3( e2.value(), e2.category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal against normal (inequal, value, generic)
{
sys::error_code e2( 0, sys::generic_category() );
sys::error_code e3( EINVAL, sys::generic_category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal against normal (inequal, value, system)
{
sys::error_code e2( 1, sys::system_category() );
sys::error_code e3( 2, sys::system_category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal against normal (inequal, category)
{
sys::error_code e2( 0, sys::system_category() );
sys::error_code e3( 0, sys::generic_category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// empty against normal
{
sys::error_code e2;
sys::error_code e3( e2.value(), e2.category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// std:: wrapping against normal
{
std::error_code e1( EINVAL, std::generic_category() );
sys::error_code e2( e1 );
sys::error_code e3( e2.value(), e2.category() );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// empty against wrapping std:: empty
{
std::error_code e1;
sys::error_code e2( e1 );
sys::error_code e3;
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// empty against roundtrip via std
{
sys::error_code e2;
std::error_code e1( e2 );
sys::error_code e3( e1 );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal/generic against roundtrip via std
{
sys::error_code e2( EINVAL, boost::system::generic_category() );
std::error_code e1( e2 );
sys::error_code e3( e1 );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
// normal/system against roundtrip via std
{
sys::error_code e2( 0, boost::system::system_category() );
std::error_code e1( e2 );
sys::error_code e3( e1 );
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
}
return boost::report_errors();
}

112
test/ec_location_test.cpp Normal file
View File

@ -0,0 +1,112 @@
// Copyright 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
int main()
{
int const val = ENOENT;
boost::system::error_category const & cat = boost::system::generic_category();
{
boost::system::error_code ec( val, cat );
BOOST_TEST_EQ( ec.value(), val );
BOOST_TEST_EQ( &ec.category(), &cat );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
boost::system::error_code ec( val, cat, &loc );
BOOST_TEST_EQ( ec.value(), val );
BOOST_TEST_EQ( &ec.category(), &cat );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 27 );
}
{
boost::system::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &boost::system::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec = boost::system::error_code( val, cat, &loc );
BOOST_TEST_EQ( ec.value(), val );
BOOST_TEST_EQ( &ec.category(), &cat );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 51 );
}
{
boost::system::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &boost::system::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( val, cat, &loc );
BOOST_TEST_EQ( ec.value(), val );
BOOST_TEST_EQ( &ec.category(), &cat );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 75 );
}
{
std::error_code e2( val, std::generic_category() );
boost::system::error_code ec( e2 );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( val, cat, &loc );
BOOST_TEST_EQ( ec.value(), val );
BOOST_TEST_EQ( &ec.category(), &cat );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 98 );
}
return boost::report_errors();
}

279
test/ec_location_test2.cpp Normal file
View File

@ -0,0 +1,279 @@
// Copyright 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
namespace sys = boost::system;
enum E
{
none = 0,
einval = EINVAL
};
namespace boost
{
namespace system
{
template<> struct is_error_code_enum< ::E >
{
static const bool value = true;
};
} // namespace system
} // namespace boost
sys::error_code make_error_code( E e )
{
return e == 0? sys::error_code(): sys::error_code( e, sys::generic_category() );
}
enum E2
{
e2inval = EINVAL
};
namespace boost
{
namespace system
{
template<> struct is_error_code_enum< ::E2 >
{
static const bool value = true;
};
} // namespace system
} // namespace boost
std::error_code make_error_code( E2 e )
{
return std::error_code( e, std::generic_category() );
}
int main()
{
{
sys::error_code ec( einval );
BOOST_TEST_EQ( ec.value(), EINVAL );
BOOST_TEST_EQ( &ec.category(), &sys::generic_category() );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
sys::error_code ec( einval, &loc );
BOOST_TEST_EQ( ec.value(), EINVAL );
BOOST_TEST_EQ( &ec.category(), &sys::generic_category() );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 73 );
}
{
sys::error_code ec( none );
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
sys::error_code ec( none, &loc );
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec = sys::error_code( einval, &loc );
BOOST_TEST_EQ( ec.value(), EINVAL );
BOOST_TEST_EQ( &ec.category(), &sys::generic_category() );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 123 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec = sys::error_code( none, &loc );
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( einval, &loc );
BOOST_TEST_EQ( ec.value(), EINVAL );
BOOST_TEST_EQ( &ec.category(), &sys::generic_category() );
BOOST_TEST( ec.failed() );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 171 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( none, &loc );
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
sys::error_code ec( e2inval );
BOOST_TEST_EQ( ec, std::error_code( EINVAL, std::generic_category() ) );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
sys::error_code ec( e2inval, &loc );
BOOST_TEST_EQ( ec, std::error_code( EINVAL, std::generic_category() ) );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec = sys::error_code( e2inval, &loc );
BOOST_TEST_EQ( ec, std::error_code( EINVAL, std::generic_category() ) );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST_EQ( &ec.category(), &sys::system_category() );
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( e2inval, &loc );
BOOST_TEST_EQ( ec, std::error_code( EINVAL, std::generic_category() ) );
BOOST_TEST( ec.failed() );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location().line(), 0 );
}
return boost::report_errors();
}

View File

@ -0,0 +1,86 @@
// Copyright 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
int main()
{
int const val = ENOENT;
boost::system::error_category const & cat = boost::system::generic_category();
{
boost::system::error_code ec;
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
boost::system::error_code ec2( ec, &loc );
BOOST_TEST_EQ( ec2, ec );
BOOST_TEST( !ec2.has_location() );
BOOST_TEST_EQ( ec2.location(), boost::source_location() );
boost::system::error_code ec3( ec2, 0 );
BOOST_TEST_EQ( ec3, ec2 );
BOOST_TEST( !ec3.has_location() );
BOOST_TEST_EQ( ec3.location(), boost::source_location() );
}
{
boost::system::error_code ec( val, cat );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
boost::system::error_code ec2( ec, &loc );
BOOST_TEST_EQ( ec2, ec );
BOOST_TEST( ec2.has_location() );
BOOST_TEST_EQ( ec2.location(), loc );
boost::system::error_code ec3( ec2, 0 );
BOOST_TEST_EQ( ec3, ec2 );
BOOST_TEST( !ec3.has_location() );
BOOST_TEST_EQ( ec3.location(), boost::source_location() );
}
{
std::error_code e2( val, std::generic_category() );
boost::system::error_code ec( e2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
boost::system::error_code ec2( ec, &loc );
BOOST_TEST_EQ( ec2, ec );
BOOST_TEST( !ec2.has_location() );
BOOST_TEST_EQ( ec2.location(), boost::source_location() );
boost::system::error_code ec3( ec2, 0 );
BOOST_TEST_EQ( ec3, ec2 );
BOOST_TEST( !ec3.has_location() );
BOOST_TEST_EQ( ec3.location(), boost::source_location() );
}
return boost::report_errors();
}

View File

@ -0,0 +1,89 @@
// Copyright 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
int main()
{
int const val = ENOENT;
boost::system::error_category const & cat = boost::system::generic_category();
{
boost::system::error_code ec;
boost::system::error_code ec2( ec );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( ec, &loc );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
ec.assign( ec, 0 );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
}
{
boost::system::error_code ec( val, cat );
boost::system::error_code ec2( ec );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( ec, &loc );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( ec.has_location() );
BOOST_TEST_EQ( ec.location(), loc );
ec.assign( ec, 0 );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
}
{
std::error_code e2( val, std::generic_category() );
boost::system::error_code ec( e2 );
boost::system::error_code ec2( ec );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
ec.assign( ec, &loc );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
ec.assign( ec, 0 );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST( !ec.has_location() );
BOOST_TEST_EQ( ec.location(), boost::source_location() );
}
return boost::report_errors();
}

87
test/ec_what_test.cpp Normal file
View File

@ -0,0 +1,87 @@
// Copyright 2020, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/system/system_category.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST( ec.category() == sys::system_category() );
BOOST_TEST_EQ( ec.what(), ec.message() + " [system:0]" );
}
{
sys::error_code ec( 5, sys::generic_category() );
BOOST_TEST_EQ( ec.value(), 5 );
BOOST_TEST( ec.category() == sys::generic_category() );
BOOST_TEST_EQ( ec.what(), ec.message() + " [generic:5]" );
}
{
sys::error_code ec( 5, sys::system_category() );
BOOST_TEST_EQ( ec.value(), 5 );
BOOST_TEST( ec.category() == sys::system_category() );
BOOST_TEST_EQ( ec.what(), ec.message() + " [system:5]" );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
sys::error_code ec( 5, sys::generic_category(), &loc );
BOOST_TEST_EQ( ec.value(), 5 );
BOOST_TEST( ec.category() == sys::generic_category() );
BOOST_TEST_EQ( &ec.location(), &loc );
BOOST_TEST_EQ( ec.what(), ec.message() + " [generic:5 at " + loc.to_string() + "]" );
}
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
sys::error_code ec( 5, sys::system_category(), &loc );
BOOST_TEST_EQ( ec.value(), 5 );
BOOST_TEST( ec.category() == sys::system_category() );
BOOST_TEST_EQ( &ec.location(), &loc );
BOOST_TEST_EQ( ec.what(), ec.message() + " [system:5 at " + loc.to_string() + "]" );
}
{
std::error_code ec;
sys::error_code ec2( ec );
BOOST_TEST_EQ( ec2.what(), ec2.message() + " [std:system:0]" );
}
{
std::error_code ec( 5, std::generic_category() );
sys::error_code ec2( ec );
BOOST_TEST_EQ( ec2.what(), ec2.message() + " [std:generic:5]" );
}
{
std::error_code ec( 5, std::system_category() );
sys::error_code ec2( ec );
BOOST_TEST_EQ( ec2.what(), ec2.message() + " [std:system:5]" );
}
return boost::report_errors();
}

21
test/ec_wstream_test.cpp Normal file
View File

@ -0,0 +1,21 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
namespace sys = boost::system;
int main()
{
{
std::wostringstream os;
os << sys::error_code();
BOOST_TEST( os.str() == L"system:0" );
}
return boost::report_errors();
}

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

34
test/errc_test3.cpp Normal file
View File

@ -0,0 +1,34 @@
// Copyright 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/errc.hpp>
int main()
{
make_error_code( boost::system::errc::success ).value();
make_error_code( boost::system::errc::success ).category();
make_error_code( boost::system::errc::success ).default_error_condition();
make_error_code( boost::system::errc::success ).message();
make_error_code( boost::system::errc::success ).failed();
make_error_code( boost::system::errc::success ).clear();
make_error_condition( boost::system::errc::success ).value();
make_error_condition( boost::system::errc::success ).category();
make_error_condition( boost::system::errc::success ).message();
make_error_condition( boost::system::errc::success ).failed();
make_error_condition( boost::system::errc::success ).clear();
make_error_code( boost::system::errc::no_such_file_or_directory ).value();
make_error_code( boost::system::errc::no_such_file_or_directory ).category();
make_error_code( boost::system::errc::no_such_file_or_directory ).default_error_condition();
make_error_code( boost::system::errc::no_such_file_or_directory ).message();
make_error_code( boost::system::errc::no_such_file_or_directory ).failed();
make_error_code( boost::system::errc::no_such_file_or_directory ).clear();
make_error_condition( boost::system::errc::no_such_file_or_directory ).value();
make_error_condition( boost::system::errc::no_such_file_or_directory ).category();
make_error_condition( boost::system::errc::no_such_file_or_directory ).message();
make_error_condition( boost::system::errc::no_such_file_or_directory ).failed();
make_error_condition( boost::system::errc::no_such_file_or_directory ).clear();
}

17
test/errc_test4.cpp Normal file
View File

@ -0,0 +1,17 @@
// Copyright 2022 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/assert/source_location.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
BOOST_TEST( make_error_code( boost::system::errc::no_such_file_or_directory, &loc ).has_location() );
BOOST_TEST_EQ( make_error_code( boost::system::errc::no_such_file_or_directory, &loc ).location().to_string(), loc.to_string() );
return boost::report_errors();
}

View File

@ -8,11 +8,9 @@
// See library home page at http://www.boost.org/libs/system
// Avoid spurious VC++ warnings
# define _CRT_SECURE_NO_WARNINGS
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/snprintf.hpp>
#include <cstdio>
//
@ -23,7 +21,7 @@ class user_category: public sys::error_category
{
public:
virtual const char * name() const BOOST_NOEXCEPT
virtual const char * name() const noexcept
{
return "user";
}
@ -31,7 +29,7 @@ public:
virtual std::string message( int ev ) const
{
char buffer[ 256 ];
std::sprintf( buffer, "user message %d", ev );
boost::core::snprintf( buffer, sizeof( buffer ), "user message %d", ev );
return buffer;
}

View File

@ -0,0 +1,77 @@
// 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/system/error_category.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/snprintf.hpp>
#include <cstdio>
//
namespace sys = boost::system;
class user_category: public sys::error_category
{
public:
virtual const char * name() const noexcept
{
return "user";
}
virtual std::string message( int ev ) const
{
char buffer[ 256 ];
boost::core::snprintf( buffer, sizeof( 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>
@ -111,6 +108,7 @@ int main( int, char ** )
std::cout << "Conversion use cases...\n";
error_condition x1( errc::file_exists );
(void)x1;
//error_code x2( errc::file_exists ); // should fail to compile
make_error_code(errc::file_exists);
make_error_condition(errc::file_exists);
@ -294,29 +292,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();
}

224
test/error_code_test2.cpp Normal file
View File

@ -0,0 +1,224 @@
// Copyright 2020, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/system/system_category.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
char buffer[ 4096 ], buffer2[ 4096 ];
{
sys::error_code ec;
BOOST_TEST_EQ( ec.value(), 0 );
BOOST_TEST( ec.category() == sys::system_category() );
BOOST_TEST_EQ( ec.message(), ec.category().message( ec.value() ) );
BOOST_TEST_CSTR_EQ( ec.message( buffer, sizeof( buffer ) ), ec.category().message( ec.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec.message( buffer, sizeof( buffer ) ), ec.message().c_str() );
{
char const* msg = ec.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec.message().c_str() );
}
}
BOOST_TEST( !ec.failed() );
BOOST_TEST( !ec );
BOOST_TEST_EQ( ec.to_string(), std::string( "system:0" ) );
}
{
sys::error_code ec;
sys::error_code ec2( ec );
BOOST_TEST_EQ( ec2.value(), 0 );
BOOST_TEST( ec2.category() == sys::system_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( !ec2.failed() );
BOOST_TEST( !ec2 );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST_NOT( ec != ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:0" ) );
}
{
sys::error_code ec;
sys::error_code ec2( ec.value(), ec.category() );
BOOST_TEST_EQ( ec2.value(), 0 );
BOOST_TEST( ec2.category() == sys::system_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( !ec2.failed() );
BOOST_TEST( !ec2 );
BOOST_TEST_EQ( ec, ec2 );
BOOST_TEST_NOT( ec != ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:0" ) );
}
{
sys::error_code ec2( 5, sys::generic_category() );
BOOST_TEST_EQ( ec2.value(), 5 );
BOOST_TEST( ec2.category() == sys::generic_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( ec2.failed() );
BOOST_TEST( ec2 );
BOOST_TEST_NOT( !ec2 );
sys::error_code ec;
BOOST_TEST_NE( ec, ec2 );
BOOST_TEST_NOT( ec == ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "generic:5" ) );
}
{
sys::error_code ec2( -4, sys::generic_category() );
BOOST_TEST_EQ( ec2.value(), -4 );
BOOST_TEST( ec2.category() == sys::generic_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( ec2.failed() );
BOOST_TEST( ec2 );
BOOST_TEST_NOT( !ec2 );
sys::error_code ec;
BOOST_TEST_NE( ec, ec2 );
BOOST_TEST_NOT( ec == ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "generic:-4" ) );
}
{
sys::error_code ec2( 5, sys::system_category() );
BOOST_TEST_EQ( ec2.value(), 5 );
BOOST_TEST( ec2.category() == sys::system_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( ec2.failed() );
BOOST_TEST( ec2 );
BOOST_TEST_NOT( !ec2 );
sys::error_code ec;
BOOST_TEST_NE( ec, ec2 );
BOOST_TEST_NOT( ec == ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:5" ) );
}
{
sys::error_code ec2( -4, sys::system_category() );
BOOST_TEST_EQ( ec2.value(), -4 );
BOOST_TEST( ec2.category() == sys::system_category() );
BOOST_TEST_EQ( ec2.message(), ec2.category().message( ec2.value() ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.category().message( ec2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( ec2.message( buffer, sizeof( buffer ) ), ec2.message().c_str() );
{
char const* msg = ec2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, ec2.message().c_str() );
}
}
BOOST_TEST( ec2.failed() );
BOOST_TEST( ec2 );
BOOST_TEST_NOT( !ec2 );
sys::error_code ec;
BOOST_TEST_NE( ec, ec2 );
BOOST_TEST_NOT( ec == ec2 );
BOOST_TEST_EQ( ec2.to_string(), std::string( "system:-4" ) );
}
return boost::report_errors();
}

69
test/error_code_test3.cpp Normal file
View File

@ -0,0 +1,69 @@
// Copyright 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/system/error_code.hpp>
#include <boost/system/error_condition.hpp>
#include <boost/system/generic_category.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
enum my_errc
{
enomem_c = ENOMEM
};
enum my_errn
{
enomem_n = ENOMEM
};
namespace boost {
namespace system {
template<> struct is_error_code_enum<my_errc>
{
static const bool value = true;
};
template<> struct is_error_condition_enum<my_errn>
{
static const bool value = true;
};
} // namespace system
} // namespace boost
sys::error_code make_error_code( my_errc e )
{
return sys::error_code( e, sys::generic_category() );
}
sys::error_condition make_error_condition( my_errn e )
{
return sys::error_condition( e, sys::generic_category() );
}
int main()
{
sys::error_code ec = make_error_code( sys::errc::not_enough_memory );
sys::error_condition en( sys::errc::not_enough_memory );
BOOST_TEST_EQ( ec, en );
BOOST_TEST_EQ( en, ec );
BOOST_TEST_EQ( ec, enomem_c );
BOOST_TEST_EQ( enomem_c, ec );
BOOST_TEST_EQ( ec, enomem_n );
BOOST_TEST_EQ( enomem_n, ec );
BOOST_TEST_EQ( en, enomem_c );
BOOST_TEST_EQ( enomem_c, en );
BOOST_TEST_EQ( en, enomem_n );
BOOST_TEST_EQ( enomem_n, en );
return boost::report_errors();
}

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

@ -0,0 +1,224 @@
// Copyright 2020, 2021 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/generic_category.hpp>
#include <boost/system/system_category.hpp>
#include <boost/core/lightweight_test.hpp>
namespace sys = boost::system;
int main()
{
char buffer[ 4096 ], buffer2[ 4096 ];
{
sys::error_condition en;
BOOST_TEST_EQ( en.value(), 0 );
BOOST_TEST( en.category() == sys::generic_category() );
BOOST_TEST_EQ( en.message(), en.category().message( en.value() ) );
BOOST_TEST_CSTR_EQ( en.message( buffer, sizeof( buffer ) ), en.category().message( en.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en.message( buffer, sizeof( buffer ) ), en.message().c_str() );
{
char const* msg = en.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en.message().c_str() );
}
}
BOOST_TEST( !en.failed() );
BOOST_TEST( !en );
BOOST_TEST_EQ( en.to_string(), std::string( "cond:generic:0" ) );
}
{
sys::error_condition en;
sys::error_condition en2( en );
BOOST_TEST_EQ( en2.value(), 0 );
BOOST_TEST( en2.category() == sys::generic_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( !en2.failed() );
BOOST_TEST( !en2 );
BOOST_TEST_EQ( en, en2 );
BOOST_TEST_NOT( en != en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:0" ) );
}
{
sys::error_condition en;
sys::error_condition en2( en.value(), en.category() );
BOOST_TEST_EQ( en2.value(), 0 );
BOOST_TEST( en2.category() == sys::generic_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( !en2.failed() );
BOOST_TEST( !en2 );
BOOST_TEST_EQ( en, en2 );
BOOST_TEST_NOT( en != en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:0" ) );
}
{
sys::error_condition en2( 5, sys::generic_category() );
BOOST_TEST_EQ( en2.value(), 5 );
BOOST_TEST( en2.category() == sys::generic_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( en2.failed() );
BOOST_TEST( en2 );
BOOST_TEST_NOT( !en2 );
sys::error_condition en;
BOOST_TEST_NE( en, en2 );
BOOST_TEST_NOT( en == en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:5" ) );
}
{
sys::error_condition en2( -4, sys::generic_category() );
BOOST_TEST_EQ( en2.value(), -4 );
BOOST_TEST( en2.category() == sys::generic_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( en2.failed() );
BOOST_TEST( en2 );
BOOST_TEST_NOT( !en2 );
sys::error_condition en;
BOOST_TEST_NE( en, en2 );
BOOST_TEST_NOT( en == en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:generic:-4" ) );
}
{
sys::error_condition en2( 5, sys::system_category() );
BOOST_TEST_EQ( en2.value(), 5 );
BOOST_TEST( en2.category() == sys::system_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( en2.failed() );
BOOST_TEST( en2 );
BOOST_TEST_NOT( !en2 );
sys::error_condition en;
BOOST_TEST_NE( en, en2 );
BOOST_TEST_NOT( en == en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:system:5" ) );
}
{
sys::error_condition en2( -4, sys::system_category() );
BOOST_TEST_EQ( en2.value(), -4 );
BOOST_TEST( en2.category() == sys::system_category() );
BOOST_TEST_EQ( en2.message(), en2.category().message( en2.value() ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.category().message( en2.value(), buffer2, sizeof( buffer2 ) ) );
BOOST_TEST_CSTR_EQ( en2.message( buffer, sizeof( buffer ) ), en2.message().c_str() );
{
char const* msg = en2.message( nullptr, 0 );
if( msg != nullptr )
{
BOOST_TEST_CSTR_EQ( msg, en2.message().c_str() );
}
}
BOOST_TEST( en2.failed() );
BOOST_TEST( en2 );
BOOST_TEST_NOT( !en2 );
sys::error_condition en;
BOOST_TEST_NE( en, en2 );
BOOST_TEST_NOT( en == en2 );
BOOST_TEST_EQ( en2.to_string(), std::string( "cond:system:-4" ) );
}
return boost::report_errors();
}

View File

@ -33,6 +33,12 @@ BOOST_STATIC_ASSERT( !ec3.failed() );
BOOST_STATIC_ASSERT( ec3? false: true );
BOOST_STATIC_ASSERT( !ec3 );
#if defined(__GNUC__) && __GNUC__ == 7 && __cplusplus == 201703L
// 'cat_' is not a constant expression
#else
constexpr error_condition en1( 1, system_category() );
BOOST_STATIC_ASSERT( en1.failed() );
@ -51,6 +57,8 @@ BOOST_STATIC_ASSERT( !en3.failed() );
BOOST_STATIC_ASSERT( en3? false: true );
BOOST_STATIC_ASSERT( !en3 );
#endif
int main()
{
}

View File

@ -2,11 +2,9 @@
// Copyright 2018 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// Avoid spurious VC++ warnings
#define _CRT_SECURE_NO_WARNINGS
#include <boost/system/error_code.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/core/snprintf.hpp>
#include <cstdio>
using namespace boost::system;
@ -15,11 +13,11 @@ struct http_category_impl: public error_category
{
// clang++ 3.8 and below: initialization of const object
// requires a user-provided default constructor
BOOST_SYSTEM_CONSTEXPR http_category_impl() BOOST_NOEXCEPT
BOOST_SYSTEM_CONSTEXPR http_category_impl() noexcept
{
}
char const * name() const BOOST_NOEXCEPT
char const * name() const noexcept
{
return "http";
}
@ -28,11 +26,11 @@ struct http_category_impl: public error_category
{
char buffer[ 32 ];
std::sprintf( buffer, "HTTP/1.0 %d", ev );
boost::core::snprintf( buffer, sizeof( buffer ), "HTTP/1.0 %d", ev );
return buffer;
}
bool failed( int ev ) const BOOST_NOEXCEPT
bool failed( int ev ) const noexcept
{
return !( ev >= 200 && ev < 300 );
}
@ -123,13 +121,13 @@ template<class Ec> void test()
{
Ec ec( 0, http_category() );
BOOST_TEST( ec.failed() );
TEST_FAILED( ec );
ec.assign( 200, http_category() );
BOOST_TEST( !ec.failed() );
TEST_NOT_FAILED( ec );
ec = Ec( 404, http_category() );
BOOST_TEST( ec.failed() );
TEST_FAILED( ec );
}
}

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

@ -16,8 +16,10 @@
#include <boost/detail/lightweight_test.hpp>
#include <boost/system/error_code.hpp>
int main( int, char*[] )
int main()
{
boost::system::error_code ec( 0, boost::system::system_category() );
return ::boost::report_errors();
boost::system::error_code ec( 0, boost::system::system_category() );
(void)ec;
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

@ -1,14 +1,10 @@
// Copyright 2017 Peter Dimov.
//
// Copyright 2017, 2021 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// https://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/system
#include <boost/system/error_code.hpp>
#include <boost/system.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cerrno>
@ -32,5 +28,16 @@ int main()
BOOST_TEST( bc == bn );
boost::system::error_code bc2 = make_error_code( boost::system::errc::no_such_file_or_directory );
BOOST_TEST_EQ( bc2, bc );
BOOST_TEST_EQ( bc2.value(), ev );
BOOST_TEST_EQ( &bc.category(), &bt );
boost::system::system_error x( bc, "prefix" );
BOOST_TEST_EQ( x.code(), bc );
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.what() );
return boost::report_errors();
}

149
test/result_and_eq_fn1r.cpp Normal file
View File

@ -0,0 +1,149 @@
// Copyright 2017, 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
struct X
{
int v_;
};
struct Y
{
int v_;
explicit Y( int v ): v_( v ) {}
Y( X x ): v_( x.v_) {}
Y( Y const& ) = delete;
Y& operator=( Y const& ) = delete;
Y( Y&& r ): v_( r.v_ )
{
r.v_ = 0;
}
Y& operator=( Y&& r )
{
if( &r != this )
{
v_ = r.v_;
r.v_ = 0;
}
return *this;
}
};
struct E
{
};
struct E2
{
E2() {}
E2( E ) {}
};
result<int, E> fi( int x )
{
return 2 * x + 1;
}
result<int, E2> fi2( int )
{
return E2();
}
result<X, E> fy( Y y )
{
return X{ 2 * y.v_ + 1 };
}
result<Y, E2> fy2( Y )
{
return E2();
}
result<int&, E> fri( int& )
{
static int x = 2;
return x;
}
result<int&, E2> fri2( int& )
{
return E2();
}
result<void, E2> fv()
{
return {};
}
result<void, E2> fv2()
{
return E2();
}
int main()
{
{
result<int, E2> r( 1 );
r &= fi;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 3 );
r &= fi2;
BOOST_TEST( r.has_error() );
r &= fi;
BOOST_TEST( r.has_error() );
}
{
result<Y, E2> r( in_place_value, 1 );
r &= fy;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 3 );
r &= fy2;
BOOST_TEST( r.has_error() );
r &= fy;
BOOST_TEST( r.has_error() );
}
{
int x1 = 1;
result<int&, E2> r( x1 );
r &= fri;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &*fri( x1 ) );
r &= fri2;
BOOST_TEST( r.has_error() );
r &= fri;
BOOST_TEST( r.has_error() );
}
{
result<void, E2> r;
r &= fv;
BOOST_TEST( r.has_value() );
r &= fv2;
BOOST_TEST( r.has_error() );
r &= fv;
BOOST_TEST( r.has_error() );
}
return boost::report_errors();
}

141
test/result_and_eq_fn1v.cpp Normal file
View File

@ -0,0 +1,141 @@
// Copyright 2017, 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
struct X
{
int v_;
};
struct Y
{
int v_;
explicit Y( int v ): v_( v ) {}
Y( X x ): v_( x.v_) {}
Y( Y const& ) = delete;
Y& operator=( Y const& ) = delete;
Y( Y&& r ): v_( r.v_ )
{
r.v_ = 0;
}
Y& operator=( Y&& r )
{
if( &r != this )
{
v_ = r.v_;
r.v_ = 0;
}
return *this;
}
};
struct E
{
};
int f( int x )
{
return x * 2 + 1;
}
X g( Y y )
{
return X{ y.v_ * 2 + 1 };
}
int& h( int& )
{
static int x = 2;
return x;
}
static int fv_called;
void fv()
{
++fv_called;
}
int main()
{
{
result<int> r( 1 );
r &= f;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( *r, 3 );
}
{
result<int, E> r( in_place_error );
r &= f;
BOOST_TEST( r.has_error() );
}
{
result<Y> r( in_place_value, 1 );
r &= g;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( r->v_, 3 );
}
{
result<Y, E> r( in_place_error );
r &= g;
BOOST_TEST( r.has_error() );
}
{
int x1 = 1;
result<int&> r( x1 );
r &= h;
BOOST_TEST( r.has_value() ) && BOOST_TEST_EQ( &*r, &h( x1 ) );
}
{
result<int&, E> r( in_place_error );
r &= h;
BOOST_TEST( r.has_error() );
}
{
result<void> r;
fv_called = 0;
r &= fv;
BOOST_TEST( r.has_value() );
BOOST_TEST_EQ( fv_called, 1 );
}
{
result<void, E> r( in_place_error );
fv_called = 0;
r &= fv;
BOOST_TEST( r.has_error() );
BOOST_TEST_EQ( fv_called, 0 );
}
return boost::report_errors();
}

503
test/result_and_fn1r.cpp Normal file
View File

@ -0,0 +1,503 @@
// Copyright 2017, 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
struct X
{
int v_;
};
struct Y
{
int v_;
explicit Y( int v ): v_( v ) {}
Y( X x ): v_( x.v_) {}
Y( Y const& ) = delete;
Y& operator=( Y const& ) = delete;
Y( Y&& r ): v_( r.v_ )
{
r.v_ = 0;
}
Y& operator=( Y&& ) = delete;
};
struct E
{
};
struct E2
{
E2() {}
E2( E ) {}
};
result<int, E2> fi( int x )
{
return 2 * x + 1;
}
result<int, E2> fi2( int )
{
return E2();
}
result<void, E2> fi3( int )
{
return {};
}
result<X, E2> fy( Y y )
{
return X{ 2 * y.v_ + 1 };
}
result<X, E2> fy2( Y )
{
return E2();
}
result<void, E2> fy3( Y )
{
return {};
}
result<int, E2> fri( int& x )
{
return x * 2 + 1;
}
result<int&, E2> fri2( int& )
{
return E2();
}
result<void, E2> fri3( int& )
{
return {};
}
result<int, E2> fk()
{
return 7;
}
result<int, E2> fk2()
{
return E2();
}
result<void, E2> fk3()
{
return {};
}
result<void, E2> fk4()
{
return E2();
}
int main()
{
{
result<int, E> r( 1 );
{
result<int, E2> r2 = r & fi;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int, E2> r2 = r & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fi3;
BOOST_TEST( r2.has_value() );
}
}
{
result<int, E> const r( 1 );
{
result<int, E2> r2 = r & fi;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int, E2> r2 = r & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fi3;
BOOST_TEST( r2.has_value() );
}
}
{
result<int, E2> r2 = result<int, E>( 1 ) & fi;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int, E2> r2 = result<int, E>( 1 ) & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<int, E>( 1 ) & fi3;
BOOST_TEST( r2.has_value() );
}
{
result<int, E> r( in_place_error );
{
result<int, E2> r2 = r & fi;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fi3;
BOOST_TEST( r2.has_error() );
}
}
{
result<int, E> const r( in_place_error );
{
result<int, E2> r2 = r & fi;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fi3;
BOOST_TEST( r2.has_error() );
}
}
{
result<int, E2> r2 = result<int, E>( in_place_error ) & fi;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = result<int, E>( in_place_error ) & fi2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<int, E>( in_place_error ) & fi3;
BOOST_TEST( r2.has_error() );
}
{
result<X, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( r2->v_, 3 );
}
{
result<X, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<Y, E>( in_place_value, 1 ) & fy3;
BOOST_TEST( r2.has_value() );
}
{
result<X, E2> r2 = result<Y, E>( in_place_error ) & fy;
BOOST_TEST( r2.has_error() );
}
{
result<X, E2> r2 = result<Y, E>( in_place_error ) & fy2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<Y, E>( in_place_error ) & fy3;
BOOST_TEST( r2.has_error() );
}
{
int x1 = 1;
result<int&, E> r( x1 );
{
result<int, E2> r2 = r & fri;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int&, E2> r2 = r & fri2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fri3;
BOOST_TEST( r2.has_value() );
}
}
{
int x1 = 1;
result<int&, E> const r( x1 );
{
result<int, E2> r2 = r & fri;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int&, E2> r2 = r & fri2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fri3;
BOOST_TEST( r2.has_value() );
}
}
{
int x1 = 1;
result<int, E2> r2 = result<int&, E>( x1 ) & fri;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
int x1 = 1;
result<int&, E2> r2 = result<int&, E>( x1 ) & fri2;
BOOST_TEST( r2.has_error() );
}
{
int x1 = 1;
result<void, E2> r2 = result<int&, E>( x1 ) & fri3;
BOOST_TEST( r2.has_value() );
}
{
result<int&, E> r( in_place_error );
{
result<int, E2> r2 = r & fri;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = r & fri2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fri3;
BOOST_TEST( r2.has_error() );
}
}
{
result<int&, E> const r( in_place_error );
{
result<int, E2> r2 = r & fri;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = r & fri2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fri3;
BOOST_TEST( r2.has_error() );
}
}
{
result<int, E2> r2 = result<int&, E>( in_place_error ) & fri;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E2> r2 = result<int&, E>( in_place_error ) & fri2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<int&, E>( in_place_error ) & fri3;
BOOST_TEST( r2.has_error() );
}
{
result<void, E> r;
{
result<int, E2> r2 = r & fk;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<int, E2> r2 = r & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk3;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = r & fk4;
BOOST_TEST( r2.has_error() );
}
}
{
result<void, E> const r;
{
result<int, E2> r2 = r & fk;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<int, E2> r2 = r & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk3;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = r & fk4;
BOOST_TEST( r2.has_error() );
}
}
{
result<int, E2> r2 = result<void, E>() & fk;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<int, E2> r2 = result<void, E>() & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<void, E>() & fk3;
BOOST_TEST( r2.has_value() );
}
{
result<void, E2> r2 = result<void, E>() & fk4;
BOOST_TEST( r2.has_error() );
}
{
result<void, E> r( in_place_error );
{
result<int, E2> r2 = r & fk;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk3;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk4;
BOOST_TEST( r2.has_error() );
}
}
{
result<void, E> const r( in_place_error );
{
result<int, E2> r2 = r & fk;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = r & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk3;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = r & fk4;
BOOST_TEST( r2.has_error() );
}
}
{
result<int, E2> r2 = result<void, E>( in_place_error ) & fk;
BOOST_TEST( r2.has_error() );
}
{
result<int, E2> r2 = result<void, E>( in_place_error ) & fk2;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<void, E>( in_place_error ) & fk3;
BOOST_TEST( r2.has_error() );
}
{
result<void, E2> r2 = result<void, E>( in_place_error ) & fk4;
BOOST_TEST( r2.has_error() );
}
return boost::report_errors();
}

331
test/result_and_fn1v.cpp Normal file
View File

@ -0,0 +1,331 @@
// Copyright 2017, 2021, 2022 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/system/result.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::system;
struct X
{
int v_;
};
struct Y
{
int v_;
explicit Y( int v ): v_( v ) {}
Y( X x ): v_( x.v_) {}
Y( Y const& ) = delete;
Y& operator=( Y const& ) = delete;
Y( Y&& r ): v_( r.v_ )
{
r.v_ = 0;
}
Y& operator=( Y&& ) = delete;
};
struct E
{
};
int f( int x )
{
return x * 2 + 1;
}
X g( Y y )
{
return X{ y.v_ * 2 + 1 };
}
int& h( int& )
{
static int x = 2;
return x;
}
int k()
{
return 7;
}
static int fv1_called_with;
void fv1( int x )
{
fv1_called_with = x;
}
static int fv2_called;
void fv2()
{
++fv2_called;
}
int main()
{
{
result<int> r( 1 );
result<int> r2 = r & f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int> const r( 1 );
result<int> r2 = r & f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int> r2 = result<int>( 1 ) & f;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 3 );
}
{
result<int, E> r( in_place_error );
result<int, E> r2 = r & f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> const r( in_place_error );
result<int, E> r2 = r & f;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> r2 = result<int, E>( in_place_error ) & f;
BOOST_TEST( r2.has_error() );
}
{
result<X> r2 = result<Y>( in_place_value, 1 ) & g;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( r2->v_, 3 );
}
{
result<X, E> r2 = result<Y, E>( in_place_error ) & g;
BOOST_TEST( r2.has_error() );
}
{
int x1 = 1;
result<int&> r( x1 );
result<int&> r2 = r & h;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
}
{
int x1 = 1;
result<int&> const r( x1 );
result<int&> r2 = r & h;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
}
{
int x1 = 1;
result<int&> r2 = result<int&>( x1 ) & h;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( &*r2, &h( x1 ) );
}
{
result<int&, E> r( in_place_error );
result<int&, E> r2 = r & h;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E> const r( in_place_error );
result<int&, E> r2 = r & h;
BOOST_TEST( r2.has_error() );
}
{
result<int&, E> r2 = result<int&, E>( in_place_error ) & h;
BOOST_TEST( r2.has_error() );
}
{
result<void> r;
result<int> r2 = r & k;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<void> const r;
result<int> r2 = r & k;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<int> r2 = result<void>() & k;
BOOST_TEST( r2.has_value() ) && BOOST_TEST_EQ( *r2, 7 );
}
{
result<void, E> r( in_place_error );
result<int, E> r2 = r & k;
BOOST_TEST( r2.has_error() );
}
{
result<void, E> const r( in_place_error );
result<int, E> r2 = r & k;
BOOST_TEST( r2.has_error() );
}
{
result<int, E> r2 = result<void, E>( in_place_error ) & k;
BOOST_TEST( r2.has_error() );
}
{
fv1_called_with = 0;
result<int> r( 1 );
result<void> r2 = r & fv1;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv1_called_with, 1 );
}
{
result<int> const r( 1 );
result<void> r2 = r & fv1;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv1_called_with, 1 );
}
{
fv1_called_with = 0;
result<void> r2 = result<int>( 1 ) & fv1;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv1_called_with, 1 );
}
{
fv1_called_with = 0;
result<int, E> r( in_place_error );
result<void, E> r2 = r & fv1;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv1_called_with, 0 );
}
{
fv1_called_with = 0;
result<int, E> const r( in_place_error );
result<void, E> r2 = r & fv1;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv1_called_with, 0 );
}
{
fv1_called_with = 0;
result<void, E> r2 = result<int, E>( in_place_error ) & fv1;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv1_called_with, 0 );
}
{
result<void> r;
fv2_called = 0;
result<void> r2 = r & fv2;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv2_called, 1 );
}
{
result<void> const r;
fv2_called = 0;
result<void> r2 = r & fv2;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv2_called, 1 );
}
{
fv2_called = 0;
result<void> r2 = result<void>() & fv2;
BOOST_TEST( r2.has_value() );
BOOST_TEST_EQ( fv2_called, 1 );
}
{
result<void, E> r( in_place_error );
fv2_called = 0;
result<void, E> r2 = r & fv2;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv2_called, 0 );
}
{
result<void, E> const r( in_place_error );
fv2_called = 0;
result<void, E> r2 = r & fv2;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv2_called, 0 );
}
{
fv2_called = 0;
result<void, E> r2 = result<void, E>( in_place_error ) & fv2;
BOOST_TEST( r2.has_error() );
BOOST_TEST_EQ( fv2_called, 0 );
}
return boost::report_errors();
}

Some files were not shown because too many files have changed in this diff Show More