mirror of
https://github.com/boostorg/system.git
synced 2025-12-27 01:08:18 +01:00
Compare commits
52 Commits
feature/up
...
boost-1.77
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b41139b28e | ||
|
|
39a19f3c90 | ||
|
|
b4dd5e98c9 | ||
|
|
41e3a7c8af | ||
|
|
aee97e91ce | ||
|
|
98533dedb3 | ||
|
|
fe811d1dd1 | ||
|
|
137ecb4abf | ||
|
|
e5cd7bf852 | ||
|
|
96cd1c0163 | ||
|
|
a9da17f2e2 | ||
|
|
f26dfd3dd7 | ||
|
|
d09c998eb2 | ||
|
|
2374e85dc7 | ||
|
|
9167bf8ee8 | ||
|
|
7f7a9da4d5 | ||
|
|
67ae4d3c47 | ||
|
|
ee028e2f9d | ||
|
|
7657188802 | ||
|
|
210c54b09a | ||
|
|
87bb5616a8 | ||
|
|
6de562c79d | ||
|
|
8efb96350f | ||
|
|
88a7be42b5 | ||
|
|
a3225e78e2 | ||
|
|
3c469fe710 | ||
|
|
c2d044f34e | ||
|
|
9fdfa6c645 | ||
|
|
42a257e17c | ||
|
|
26d0d32c54 | ||
|
|
70b5449e99 | ||
|
|
8043ce0278 | ||
|
|
83a2933afa | ||
|
|
2e707ca921 | ||
|
|
a6c4b6329c | ||
|
|
5b1909eba4 | ||
|
|
9dc13fd82a | ||
|
|
e9cdb10409 | ||
|
|
e625bd0eea | ||
|
|
66656f7044 | ||
|
|
0d8511f571 | ||
|
|
fbc49bbaa0 | ||
|
|
344eb1e1f8 | ||
|
|
20b8e90dff | ||
|
|
a0136e570d | ||
|
|
6586fcb01e | ||
|
|
b74b1e3c8c | ||
|
|
f8ab3df822 | ||
|
|
f6fb85d7d3 | ||
|
|
9cd9d8732f | ||
|
|
1b7fd6854d | ||
|
|
610d5f3f78 |
21
.travis.yml
21
.travis.yml
@@ -65,14 +65,19 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
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++-10
|
||||
- g++-11
|
||||
sources:
|
||||
- sourceline: "ppa:ubuntu-toolchain-r/test"
|
||||
|
||||
@@ -95,15 +100,15 @@ matrix:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-11
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,20 UBSAN_OPTIONS=print_stacktrace=1
|
||||
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-11
|
||||
- clang-12
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
@@ -206,7 +211,7 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/system/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover 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:
|
||||
|
||||
@@ -30,8 +30,12 @@ environment:
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
@@ -67,4 +71,4 @@ 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
|
||||
- b2 -j3 libs/system/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
|
||||
@@ -27,6 +27,11 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
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
|
||||
|
||||
|
||||
@@ -567,6 +567,8 @@ namespace boost {
|
||||
template <class ErrorCodeEnum>
|
||||
constexpr error_code( ErrorCodeEnum e ) noexcept;
|
||||
|
||||
error_code( std::error_code const& ec ) noexcept;
|
||||
|
||||
// modifiers:
|
||||
|
||||
constexpr void assign( int val, const error_category & cat ) noexcept;
|
||||
@@ -593,33 +595,58 @@ namespace boost {
|
||||
|
||||
friend constexpr bool operator==( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator!=( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator<( const error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
friend bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
friend bool operator==( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
friend bool operator==( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
friend bool operator!=( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
|
||||
template<class E>
|
||||
friend constexpr bool operator==( const error_code & lhs, E rhs ) noexcept;
|
||||
template<class E>
|
||||
friend constexpr bool operator==( E lhs, const error_code & rhs ) noexcept;
|
||||
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( const error_code & lhs, E rhs ) noexcept;
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( E lhs, const error_code & rhs ) noexcept;
|
||||
|
||||
// conversions:
|
||||
|
||||
operator std::error_code() const;
|
||||
operator std::error_code();
|
||||
template<class T> operator T& (); // only when T=std::error_code
|
||||
|
||||
// stream insertion:
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
};
|
||||
|
||||
// non-member functions
|
||||
|
||||
bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_code & ec );
|
||||
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
|
||||
}
|
||||
@@ -654,6 +681,15 @@ template <class ErrorCodeEnum>
|
||||
Ensures: :: `*this == make_error_code( e )`.
|
||||
Remarks: :: This constructor is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`.
|
||||
|
||||
```
|
||||
error_code( std::error_code const & ec ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: Construct an `error_code` that wraps `ec`.
|
||||
Remarks: :: `value()` and `category()` are unspecified.
|
||||
|
||||
#### Modifiers
|
||||
|
||||
```
|
||||
@@ -715,7 +751,8 @@ std::string message() const;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `category().message( value() )`.
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec.message()`.
|
||||
Otherwise, `category().message( value() )`.
|
||||
|
||||
```
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
@@ -723,7 +760,9 @@ char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `category().message( value(), buffer, len )`.
|
||||
Effects: :: If `*this` wraps a `std::error_code` object `ec`, copies the
|
||||
string returned from `ec.message()` into `buffer` and returns `buffer`.
|
||||
Otherwise, returns `category().message( value(), buffer, len )`.
|
||||
|
||||
```
|
||||
constexpr bool failed() const noexcept;
|
||||
@@ -731,7 +770,8 @@ constexpr bool failed() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `category().failed( value() )`.
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec.value() != 0`.
|
||||
Otherwise, `category().failed( value() )`.
|
||||
|
||||
```
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
@@ -751,7 +791,8 @@ friend constexpr bool operator==( const error_code & lhs,
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `lhs.value() == rhs.value() && lhs.category() == rhs.category()`.
|
||||
Returns: :: If both `lhs` and `rhs` wrap `std::error_code` objects `e1` and `e2`, `e1 == e2`.
|
||||
Otherwise, `lhs.value() == rhs.value() && lhs.category() == rhs.category()`.
|
||||
|
||||
```
|
||||
friend constexpr bool operator!=( const error_code & lhs,
|
||||
@@ -769,43 +810,138 @@ friend constexpr bool operator<( const error_code & lhs,
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If both `lhs` and `rhs` wrap `std::error_code` objects `e1` and `e2`, `e1 < e2`.
|
||||
Otherwise, `lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value())`.
|
||||
|
||||
```
|
||||
friend bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: If `code` wraps a `std::error_code` object `ec`, `ec == static_cast<std::error_condition>( condition )`.
|
||||
Otherwise, `code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() )`.
|
||||
|
||||
```
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator!=( const error_condition & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
friend bool operator==( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `static_cast<std::error_code>(lhs) == rhs`.
|
||||
|
||||
```
|
||||
friend bool operator==( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `lhs == static_cast<std::error_code>(rhs)`.
|
||||
|
||||
```
|
||||
friend bool operator!=( const error_code & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator!=( const std::error_code & lhs,
|
||||
const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value())`.
|
||||
`!( lhs == rhs )`.
|
||||
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator==( const error_code & lhs, E rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
[disc]
|
||||
** When `is_error_code_enum<E>::value` is `true`, returns `lhs == make_error_code(rhs)`;
|
||||
** When `is_error_condition_enum<E>::value` is `true`, returns `lhs == make_error_condition(rhs)`;
|
||||
** Otherwise, this overload is disabled.
|
||||
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator==( E lhs, const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: ::
|
||||
[disc]
|
||||
** When `is_error_code_enum<E>::value` is `true`, returns `make_error_code(lhs) == rhs`;
|
||||
** When `is_error_condition_enum<E>::value` is `true`, returns `make_error_condition(lhs) == rhs`;
|
||||
** Otherwise, this overload is disabled.
|
||||
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( const error_code & lhs, E rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
template<class E>
|
||||
friend constexpr bool operator!=( E lhs, const error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
Remarks: :: These overloads are only enabled when
|
||||
`is_error_code_enum<E>::value` is `true` or
|
||||
`is_error_condition_enum<E>::value` is `true`.
|
||||
|
||||
#### Conversions
|
||||
|
||||
```
|
||||
operator std::error_code() const;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`std::error_code( value(), category() )`.
|
||||
|
||||
#### Nonmembers
|
||||
|
||||
```
|
||||
bool operator==( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator==( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
operator std::error_code();
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `code.category().equivalent(code.value(), condition) || condition.category().equivalent(code, condition.value())`.
|
||||
Returns: :: If `*this` wraps a `std::error_code` object `ec`, `ec`.
|
||||
Otherwise, `std::error_code( value(), category() )`.
|
||||
|
||||
```
|
||||
bool operator!=( const error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
bool operator!=( const error_condition & condition,
|
||||
const error_code & code ) noexcept;
|
||||
template<class T> operator T&();
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `!( lhs == rhs )`.
|
||||
Effects: :: If `*this` wraps a `std::error_code` object `ec`,
|
||||
returns a reference to `ec`.
|
||||
Otherwise, makes `*this` wrap `std::error_code( *this )`,
|
||||
then returns a reference to it.
|
||||
Remarks: ::
|
||||
This operator is only enabled when `T` is `std::error_code`.
|
||||
|
||||
#### Stream Insertion
|
||||
|
||||
```
|
||||
template <class charT, class traits>
|
||||
@@ -815,8 +951,12 @@ template <class charT, class traits>
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: `os << ec.category().name() << ':' << ec.value()`.
|
||||
Returns: :: `os`.
|
||||
Effects: :: If `ec` wraps a `std::error_code` object `e2`, `os << "std:" << e2`.
|
||||
Otherwise, `os << ec.category().name() << ':' << ec.value()`.
|
||||
Returns: ::
|
||||
`os`.
|
||||
|
||||
#### Nonmembers
|
||||
|
||||
```
|
||||
std::size_t hash_value( const error_code & ec );
|
||||
@@ -824,8 +964,8 @@ std::size_t hash_value( const error_code & ec );
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
A hash value representing `ec`.
|
||||
Returns: :: If `ec` wraps a `std::error_code` object `e2`, `std::hash<std::error_code>()(e2)`.
|
||||
Otherwise, a hash value representing `ec`.
|
||||
|
||||
## <boost/system/{zwsp}error_condition.hpp>
|
||||
|
||||
@@ -870,15 +1010,32 @@ namespace boost {
|
||||
|
||||
friend constexpr bool operator==( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator!=( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend constexpr bool operator<( const error_condition & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
|
||||
friend bool operator==( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
|
||||
friend bool operator!=( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
friend bool operator!=( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
|
||||
// conversions:
|
||||
|
||||
operator std::error_condition() const;
|
||||
|
||||
// stream insertion:
|
||||
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_condition & en );
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1023,6 +1180,33 @@ friend constexpr bool operator<( const error_condition & lhs,
|
||||
Returns: ::
|
||||
`lhs.category() < rhs.category() || (lhs.category() == rhs.category() && lhs.value() < rhs.value())`.
|
||||
|
||||
```
|
||||
friend bool operator==( const std::error_code & code,
|
||||
const error_condition & condition ) noexcept;
|
||||
```
|
||||
```
|
||||
friend bool operator==( const error_condition & condition,
|
||||
const std::error_code & code ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `code == static_cast<std::error_condition>( rhs )`.
|
||||
|
||||
```
|
||||
friend constexpr bool operator!=( const std::error_code & lhs,
|
||||
const error_condition & rhs ) noexcept;
|
||||
```
|
||||
```
|
||||
friend constexpr bool operator!=( const error_condition & lhs,
|
||||
const std::error_code & rhs ) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: ::
|
||||
`!( lhs == rhs )`.
|
||||
|
||||
#### Conversions
|
||||
|
||||
```
|
||||
@@ -1034,6 +1218,20 @@ operator std::error_condition() const;
|
||||
Returns: ::
|
||||
`std::error_condition( value(), category() )`.
|
||||
|
||||
#### Stream Insertion
|
||||
|
||||
```
|
||||
template <class charT, class traits>
|
||||
std::basic_ostream<charT, traits>&
|
||||
operator<<( basic_ostream<charT, traits>& os, const error_condition & en );
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects: :: `os << "cond:" << en.category().name() << ':' << en.value()`.
|
||||
Returns: ::
|
||||
`os`.
|
||||
|
||||
## <boost/system/{zwsp}system_error.hpp>
|
||||
|
||||
### Class system_error
|
||||
|
||||
@@ -56,4 +56,10 @@
|
||||
# define BOOST_SYSTEM_DEPRECATED(msg)
|
||||
#endif
|
||||
|
||||
// BOOST_SYSTEM_CLANG_6
|
||||
|
||||
#if defined(__clang__) && (__clang_major__ < 7 || (defined(__APPLE__) && __clang_major__ < 11))
|
||||
# define BOOST_SYSTEM_CLANG_6
|
||||
#endif
|
||||
|
||||
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
|
||||
|
||||
@@ -172,6 +172,7 @@ namespace detail
|
||||
|
||||
static const boost::ulong_long_type generic_category_id = ( boost::ulong_long_type( 0xB2AB117A ) << 32 ) + 0x257EDF0D;
|
||||
static const boost::ulong_long_type system_category_id = ( boost::ulong_long_type( 0x8FAFD21E ) << 32 ) + 0x25C5E09B;
|
||||
static const boost::ulong_long_type interop_category_id = ( boost::ulong_long_type( 0x943F2817 ) << 32 ) + 0xFD3A8FAF;
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool failed_impl( int ev, error_category const & cat )
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#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/config.hpp>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
@@ -83,7 +84,8 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
catch( ... )
|
||||
{
|
||||
return "Message text unavailable";
|
||||
detail::snprintf( buffer, len, "No message text available for error %d", ev );
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -10,15 +10,29 @@
|
||||
//
|
||||
// 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/is_error_code_enum.hpp>
|
||||
#include <boost/system/detail/is_same.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <ostream>
|
||||
#include <new>
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
# include <system_error>
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40600 && BOOST_GCC < 70000
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -35,26 +49,50 @@ namespace system
|
||||
// and error_code containing a pointer to an object of a type derived
|
||||
// from error_category.
|
||||
|
||||
std::size_t hash_value( error_code const & ec );
|
||||
|
||||
class error_code
|
||||
{
|
||||
private:
|
||||
|
||||
int val_;
|
||||
bool failed_;
|
||||
const error_category * cat_;
|
||||
friend std::size_t hash_value( error_code const & ec );
|
||||
|
||||
private:
|
||||
|
||||
struct data
|
||||
{
|
||||
int val_;
|
||||
const error_category * cat_;
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
data d1_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
unsigned char d2_[ sizeof(std::error_code) ];
|
||||
#endif
|
||||
};
|
||||
|
||||
// 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
|
||||
unsigned flags_;
|
||||
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code() BOOST_NOEXCEPT:
|
||||
val_( 0 ), failed_( false ), cat_( &system_category() )
|
||||
d1_(), flags_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_code( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||
d1_(), flags_( 2 + detail::failed_impl( val, cat ) )
|
||||
{
|
||||
d1_.val_ = val;
|
||||
d1_.cat_ = &cat;
|
||||
}
|
||||
|
||||
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
||||
@@ -63,13 +101,21 @@ public:
|
||||
*this = make_error_code( e );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
error_code( std::error_code const& ec ) BOOST_NOEXCEPT:
|
||||
flags_( 1 )
|
||||
{
|
||||
::new( d2_ ) std::error_code( ec );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// modifiers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = val;
|
||||
failed_ = detail::failed_impl( val, cat );
|
||||
cat_ = &cat;
|
||||
*this = error_code( val, cat );
|
||||
}
|
||||
|
||||
template<typename ErrorCodeEnum>
|
||||
@@ -82,48 +128,113 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = &system_category();
|
||||
*this = error_code();
|
||||
}
|
||||
|
||||
// observers:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR int value() const BOOST_NOEXCEPT
|
||||
{
|
||||
return val_;
|
||||
if( flags_ != 1 )
|
||||
{
|
||||
return d1_.val_;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.value() + 1000 * static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
||||
#else
|
||||
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR const error_category & category() const BOOST_NOEXCEPT
|
||||
{
|
||||
return *cat_;
|
||||
if( flags_ == 0 )
|
||||
{
|
||||
return system_category();
|
||||
}
|
||||
else if( flags_ == 1 )
|
||||
{
|
||||
return detail::interop_category();
|
||||
}
|
||||
else
|
||||
{
|
||||
return *d1_.cat_;
|
||||
}
|
||||
}
|
||||
|
||||
// deprecated?
|
||||
error_condition default_error_condition() const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->default_error_condition( value() );
|
||||
return category().default_error_condition( value() );
|
||||
}
|
||||
|
||||
std::string message() const
|
||||
{
|
||||
return cat_->message( value() );
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.message();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return category().message( value() );
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->message( value(), buffer, len );
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
try
|
||||
#endif
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
detail::snprintf( buffer, len, "%s", ec.message().c_str() );
|
||||
return buffer;
|
||||
}
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
catch( ... )
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return category().message( value(), buffer, len );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
{
|
||||
return failed_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
return ec.value() != 0;
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return (flags_ & 1) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_;
|
||||
return failed();
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -133,12 +244,12 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_? unspecified_bool_true: 0;
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed_;
|
||||
return !failed();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -150,39 +261,266 @@ public:
|
||||
|
||||
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_;
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.flags_ == 1 && rhs.flags_ == 1 )
|
||||
{
|
||||
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
|
||||
#endif
|
||||
{
|
||||
return lhs.value() == rhs.value() && lhs.category() == rhs.category();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if( lhs.flags_ == 1 && rhs.flags_ == 1 )
|
||||
{
|
||||
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
|
||||
#endif
|
||||
{
|
||||
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 ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( code.flags_ == 1 )
|
||||
{
|
||||
return static_cast<std::error_code>( code ) == static_cast<std::error_condition>( condition );
|
||||
}
|
||||
else
|
||||
|
||||
#endif
|
||||
{
|
||||
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
||||
}
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
operator std::error_code () const
|
||||
inline friend bool operator==( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return std::error_code( value(), category() );
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( error_code const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_code const & rhs ) BOOST_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 ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_condition( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_condition( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator!=( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N = typename detail::enable_if<std::is_error_condition_enum<E>::value>::type>
|
||||
inline friend bool operator!=( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == make_error_code( rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator==( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return make_error_code( lhs ) == rhs;
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( error_code const & lhs, E rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class E, class N1 = void, class N2 = typename detail::enable_if<std::is_error_code_enum<E>::value>::type>
|
||||
BOOST_SYSTEM_CONSTEXPR inline friend bool operator!=( E lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_CLANG_6)
|
||||
|
||||
inline friend bool operator==( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_code >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator==( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == static_cast< std::error_code >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_code const & lhs, std::error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_condition const & lhs, error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// conversions
|
||||
|
||||
operator std::error_code () const
|
||||
{
|
||||
if( flags_ == 1 )
|
||||
{
|
||||
return *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
}
|
||||
else if( flags_ == 0 )
|
||||
{
|
||||
//return std::error_code();
|
||||
return std::error_code( 0, boost::system::system_category() );
|
||||
}
|
||||
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( flags_ != 1 )
|
||||
{
|
||||
std::error_code e2( *this );
|
||||
::new( d2_ ) std::error_code( e2 );
|
||||
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
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline friend std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( ec.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( ec.d2_ );
|
||||
os << "std:" << e2.category().name() << ':' << e2.value();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
os << ec.category().name() << ':' << ec.value();
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline bool operator!=( const error_code & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||
{
|
||||
os << ec.category().name() << ':' << ec.value();
|
||||
return os;
|
||||
}
|
||||
|
||||
inline std::size_t hash_value( error_code const & ec )
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( ec.flags_ == 1 )
|
||||
{
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( ec.d2_ );
|
||||
return std::hash<std::error_code>()( e2 );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
error_category const & cat = ec.category();
|
||||
|
||||
boost::ulong_long_type id_ = cat.id_;
|
||||
@@ -212,4 +550,8 @@ inline std::size_t hash_value( error_code const & ec )
|
||||
|
||||
} // 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
|
||||
|
||||
@@ -45,6 +45,7 @@ class error_condition
|
||||
private:
|
||||
|
||||
int val_;
|
||||
bool failed_;
|
||||
error_category const * cat_;
|
||||
|
||||
public:
|
||||
@@ -52,17 +53,17 @@ public:
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||
val_( 0 ), cat_( 0 )
|
||||
val_( 0 ), failed_( false ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition( int val, const error_category & cat ) BOOST_NOEXCEPT:
|
||||
val_( val ), cat_( &cat )
|
||||
val_( val ), failed_( detail::failed_impl( val, cat ) ), cat_( &cat )
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit error_condition( boost::system::detail::generic_value_tag vt ) BOOST_NOEXCEPT:
|
||||
val_( vt.value ), cat_( 0 )
|
||||
val_( vt.value ), failed_( vt.value != 0 ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
|
||||
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) BOOST_NOEXCEPT:
|
||||
val_( e ), cat_( 0 )
|
||||
val_( e ), failed_( e != 0 ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -85,6 +86,7 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = val;
|
||||
failed_ = detail::failed_impl( val, cat );
|
||||
cat_ = &cat;
|
||||
}
|
||||
|
||||
@@ -99,6 +101,7 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = 0;
|
||||
}
|
||||
|
||||
@@ -140,21 +143,14 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
{
|
||||
if( cat_ )
|
||||
{
|
||||
return detail::failed_impl( val_, *cat_ );
|
||||
}
|
||||
else
|
||||
{
|
||||
return val_ != 0;
|
||||
}
|
||||
return failed_;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed();
|
||||
return failed_;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -164,12 +160,12 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed()? unspecified_bool_true: 0;
|
||||
return failed_? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed();
|
||||
return !failed_;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -202,7 +198,38 @@ public:
|
||||
return std::error_condition( value(), category() );
|
||||
}
|
||||
|
||||
inline friend bool operator==( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return lhs == static_cast< std::error_condition >( rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator==( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast< std::error_condition >( lhs ) == rhs;
|
||||
}
|
||||
|
||||
inline friend bool operator!=( std::error_code const & lhs, error_condition const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
inline friend bool operator!=( error_condition const & lhs, std::error_code const & rhs ) BOOST_NOEXCEPT
|
||||
{
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class Ch, class Tr>
|
||||
inline friend std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_condition const & en)
|
||||
{
|
||||
{
|
||||
os << "cond:" << en.category().name() << ':' << en.value();
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
107
include/boost/system/detail/interop_category.hpp
Normal file
107
include/boost/system/detail/interop_category.hpp
Normal 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() BOOST_NOEXCEPT:
|
||||
error_category( detail::interop_category_id )
|
||||
{
|
||||
}
|
||||
|
||||
const char * name() const BOOST_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 BOOST_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 BOOST_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() BOOST_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() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
|
||||
#endif
|
||||
|
||||
inline error_category const & interop_category() BOOST_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
|
||||
70
include/boost/system/detail/snprintf.hpp
Normal file
70
include/boost/system/detail/snprintf.hpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#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 <boost/config.hpp>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) )
|
||||
|
||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
||||
{
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4996 )
|
||||
# endif
|
||||
|
||||
if( len == 0 ) return;
|
||||
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
|
||||
_vsnprintf( buffer, len - 1, format, args );
|
||||
buffer[ len - 1 ] = 0;
|
||||
|
||||
va_end( args );
|
||||
|
||||
# if defined( BOOST_MSVC )
|
||||
# pragma warning( pop )
|
||||
# endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline void snprintf( char * buffer, std::size_t len, char const * format, ... )
|
||||
{
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
|
||||
std::vsnprintf( buffer, len, format, args );
|
||||
|
||||
va_end( args );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SNPRINTF_HPP_INCLUDED
|
||||
@@ -10,6 +10,7 @@
|
||||
//
|
||||
// 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>
|
||||
@@ -27,35 +28,12 @@ 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 );
|
||||
detail::snprintf( buffer, len, "Unknown error (%d)", ev );
|
||||
return buffer;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline boost::winapi::UINT_ message_cp_win32()
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_USE_UTF8)
|
||||
|
||||
@@ -17,38 +17,5 @@
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/system/detail/throws.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
// non-member functions of error_code and error_condition
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
||||
|
||||
@@ -69,3 +69,32 @@ lib(boost_system_std_single_instance_lib2 STD_SINGLE_INSTANCE_DYN_LINK std_singl
|
||||
|
||||
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 cygwin_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)
|
||||
|
||||
@@ -56,7 +56,7 @@ system-run generic_category_test.cpp ;
|
||||
system-run system_category_test.cpp ;
|
||||
system-run after_main_test.cpp ;
|
||||
system-run failed_test.cpp ;
|
||||
compile failed_constexpr_test.cpp : <toolset>gcc,<undefined-sanitizer>norecover:<build>no ;
|
||||
system-run failed_constexpr_test.cpp ;
|
||||
|
||||
# Quick (CI) test
|
||||
run quick.cpp ;
|
||||
@@ -89,3 +89,22 @@ run system_category_test3.cpp ;
|
||||
run windows_error_test.cpp ;
|
||||
run cygwin_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 ;
|
||||
|
||||
34
test/errc_test3.cpp
Normal file
34
test/errc_test3.cpp
Normal 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();
|
||||
}
|
||||
@@ -35,28 +35,16 @@ BOOST_STATIC_ASSERT( !ec3 );
|
||||
|
||||
constexpr error_condition en1( 1, system_category() );
|
||||
|
||||
#if __GNUC__ == 7 && __cplusplus == 201703L
|
||||
// `cat_ != 0` is not a constant expression
|
||||
#else
|
||||
|
||||
BOOST_STATIC_ASSERT( en1.failed() );
|
||||
BOOST_STATIC_ASSERT( en1 );
|
||||
BOOST_STATIC_ASSERT( !!en1 );
|
||||
|
||||
#endif
|
||||
|
||||
constexpr error_condition en2( 2, generic_category() );
|
||||
|
||||
#if __GNUC__ == 7 && __cplusplus == 201703L
|
||||
// `cat_ != 0` is not a constant expression
|
||||
#else
|
||||
|
||||
BOOST_STATIC_ASSERT( en2.failed() );
|
||||
BOOST_STATIC_ASSERT( en2 );
|
||||
BOOST_STATIC_ASSERT( !!en2 );
|
||||
|
||||
#endif
|
||||
|
||||
constexpr error_condition en3;
|
||||
|
||||
BOOST_STATIC_ASSERT( !en3.failed() );
|
||||
|
||||
@@ -120,30 +120,18 @@ template<class Ec> void test()
|
||||
ec.assign( 0, generic_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
}
|
||||
}
|
||||
|
||||
template<class Ec> void test2()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
|
||||
template<class Ec> void test3()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
BOOST_TEST( !ec.failed() );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -159,9 +147,7 @@ int main()
|
||||
BOOST_TEST( http_category().failed( 404 ) );
|
||||
|
||||
test<error_code>();
|
||||
test2<error_code>();
|
||||
test<error_condition>();
|
||||
test3<error_condition>();
|
||||
|
||||
{
|
||||
error_condition ec( errc::success );
|
||||
|
||||
60
test/snprintf_test.cpp
Normal file
60
test/snprintf_test.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
char buffer[ 64 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 64 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 15 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151..." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 14 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...xy...151.." );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 5 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "...x" );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 1 ];
|
||||
boost::system::detail::snprintf( buffer, sizeof(buffer), "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_CSTR_EQ( buffer, "" );
|
||||
}
|
||||
|
||||
{
|
||||
char buffer[ 1 ] = { 'Q' };
|
||||
boost::system::detail::snprintf( buffer, 0, "...%s...%d...", "xy", 151 );
|
||||
|
||||
BOOST_TEST_EQ( buffer[0], 'Q' );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
98
test/std_interop_test2.cpp
Normal file
98
test/std_interop_test2.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright 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/system_category.hpp>
|
||||
#include <boost/system/generic_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
void f1( std::error_code ec, int value, std::error_category const& category )
|
||||
{
|
||||
BOOST_TEST_EQ( ec.value(), value );
|
||||
BOOST_TEST_EQ( &ec.category(), &category );
|
||||
}
|
||||
|
||||
void f2( std::error_code const& ec, int value, std::error_category const& category )
|
||||
{
|
||||
BOOST_TEST_EQ( ec.value(), value );
|
||||
BOOST_TEST_EQ( &ec.category(), &category );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::system_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::system_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::generic_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( ENOENT, boost::system::generic_category() );
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
f1( e1, e1.value(), e1.category() );
|
||||
#if !defined(BOOST_SYSTEM_CLANG_6)
|
||||
f2( e1, e1.value(), e1.category() );
|
||||
#endif
|
||||
|
||||
BOOST_TEST_EQ( e1, e2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
79
test/std_interop_test3.cpp
Normal file
79
test/std_interop_test3.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::error_code e1;
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( !e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::system_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 0, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( !e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( ENOENT, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = make_error_code( std::errc::no_such_file_or_directory );
|
||||
boost::system::error_code e2 = e1;
|
||||
|
||||
BOOST_TEST( e2.failed() );
|
||||
BOOST_TEST_EQ( e1.message(), e2.message() );
|
||||
|
||||
std::error_code e3 = e2;
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
89
test/std_interop_test4.cpp
Normal file
89
test/std_interop_test4.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
void f( std::error_code& e1, std::error_code e2 )
|
||||
{
|
||||
e1 = e2;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2;
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 0, std::system_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 5, std::system_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( 0, std::generic_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
std::error_code e2( ENOENT, std::generic_category() );
|
||||
|
||||
f( e1, e2 );
|
||||
|
||||
BOOST_TEST_EQ( e1, boost::system::error_code( e2 ) );
|
||||
|
||||
std::error_code e3( e1 );
|
||||
BOOST_TEST_EQ( e3, e2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
108
test/std_interop_test5.cpp
Normal file
108
test/std_interop_test5.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::error_code e1;
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::system_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 0, std::generic_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::generic_category() );
|
||||
std::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST( e1 == en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
boost::system::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
std::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST( e3 == en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
129
test/std_interop_test6.cpp
Normal file
129
test/std_interop_test6.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1;
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::system_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::system_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 0, boost::system::generic_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1( 5, boost::system::generic_category() );
|
||||
boost::system::error_condition en = e1.default_error_condition();
|
||||
|
||||
BOOST_TEST_EQ( e1, en );
|
||||
BOOST_TEST_NOT( e1 != en );
|
||||
|
||||
std::error_code e2( e1 );
|
||||
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
BOOST_TEST_EQ( e3, en );
|
||||
BOOST_TEST_NOT( e3 != en );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
52
test/std_interop_test7.cpp
Normal file
52
test/std_interop_test7.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( boost::system::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == boost::system::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != boost::system::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == std::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != std::errc::bad_address );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( std::errc::bad_address );
|
||||
|
||||
BOOST_TEST( e1 == boost::system::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != boost::system::errc::bad_address );
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC >= 40800 && BOOST_GCC < 50000
|
||||
|
||||
// fails on g++ 4.8.5 and g++ 4.9.4 from ubuntu-toolchain-r-test for unknown reasons
|
||||
// works on the system g++ 4.8.4 on Trusty and the system g++ 4.8.5 on CentOS 7
|
||||
|
||||
#else
|
||||
BOOST_TEST( e1 == std::errc::bad_address );
|
||||
BOOST_TEST_NOT( e1 != std::errc::bad_address );
|
||||
#endif
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
82
test/std_interop_test8.cpp
Normal file
82
test/std_interop_test8.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
my_enoent = ENOENT
|
||||
};
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 70000
|
||||
|
||||
// g++ 6 and earlier do not allow specializations outside the namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<> struct is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#else
|
||||
|
||||
template<> struct boost::system::is_error_condition_enum<my_errc>: std::true_type {};
|
||||
template<> struct std::is_error_condition_enum<my_errc>: std::true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
boost::system::error_condition make_error_condition( my_errc e )
|
||||
{
|
||||
return boost::system::error_condition( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
boost::system::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return boost::system::error_code( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = make_error_code( my_enoent );
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = make_error_code( my_enoent );
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
77
test/std_interop_test9.cpp
Normal file
77
test/std_interop_test9.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
// Copyright 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/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
enum my_errc
|
||||
{
|
||||
my_enoent = ENOENT
|
||||
};
|
||||
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 70000
|
||||
|
||||
// g++ 6 and earlier do not allow specializations outside the namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<> struct is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#else
|
||||
|
||||
template<> struct boost::system::is_error_code_enum<my_errc>: std::true_type {};
|
||||
template<> struct std::is_error_code_enum<my_errc>: std::true_type {};
|
||||
|
||||
#endif
|
||||
|
||||
boost::system::error_code make_error_code( my_errc e )
|
||||
{
|
||||
return boost::system::error_code( e, boost::system::generic_category() );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::system::error_code e1 = my_enoent;
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1 = my_enoent;
|
||||
|
||||
BOOST_TEST( e1 == my_enoent );
|
||||
BOOST_TEST_NOT( e1 != my_enoent );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user