mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 08:18:05 +01:00
Compare commits
7 Commits
feature/re
...
boost-1.75
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39bd8ba98f | ||
|
|
f1c0a52426 | ||
|
|
8962c9101a | ||
|
|
329e72fb92 | ||
|
|
6758690d2f | ||
|
|
8f32183b63 | ||
|
|
99db03ee96 |
@@ -16,6 +16,7 @@ environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
|
||||
@@ -11,6 +11,23 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
# Revision History
|
||||
:idprefix:
|
||||
|
||||
## Changes in Boost 1.75
|
||||
|
||||
* The platform-specific headers `windows_error.hpp`, `linux_error.hpp`,
|
||||
and `cygwin_error.hpp` emit deprecation messages and are slated for
|
||||
removal.
|
||||
* The old names for `generic_category()` and `system_category()` emit
|
||||
deprecation messages and are slated for removal.
|
||||
* `error_condition::failed` is deprecated and is slated for removal.
|
||||
`operator bool()` for `error_condition` has been reverted to its old
|
||||
meaning of `value() != 0`. This is done for compatibility with
|
||||
`std::error_condition` as the next release is expected to improve
|
||||
interoperability with `<system_error>` even further. _Note that this
|
||||
does not affect_ `error_code::failed`, which is still alive and well.
|
||||
* The overload of `error_condition::message` that takes a buffer is
|
||||
deprecated and is slated for removal, for the same reasons. _Note that
|
||||
this does not affect_ `error_code::message`.
|
||||
|
||||
## Changes in Boost 1.74
|
||||
|
||||
* `operator bool()` now returns `failed()` instead of `value() != 0`.
|
||||
|
||||
@@ -670,13 +670,16 @@ namespace boost {
|
||||
constexpr const error_category & category() const noexcept;
|
||||
|
||||
std::string message() const;
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
|
||||
constexpr bool failed() const noexcept;
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
|
||||
operator std::error_condition() const;
|
||||
|
||||
// deprecated members; do not use
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
constexpr bool failed() const noexcept;
|
||||
|
||||
private: // exposition only
|
||||
|
||||
int val_;
|
||||
@@ -771,29 +774,13 @@ std::string message() const;
|
||||
+
|
||||
Returns: :: `cat_\->message( val_ )`.
|
||||
|
||||
```
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_, buffer, len )`.
|
||||
|
||||
```
|
||||
constexpr bool failed() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->failed( val_ )`.
|
||||
|
||||
```
|
||||
constexpr explicit operator bool() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `failed()`.
|
||||
Returns: :: `value() != 0`.
|
||||
|
||||
```
|
||||
operator std::error_condition() const;
|
||||
@@ -804,6 +791,34 @@ operator std::error_condition() const;
|
||||
Returns: ::
|
||||
`std::error_condition( val_, *cat_ )`.
|
||||
|
||||
#### Deprecated members
|
||||
|
||||
```
|
||||
char const * message( char * buffer, std::size_t len ) const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->message( val_, buffer, len )`.
|
||||
|
||||
WARNING: This member function is deprecated and will be removed. This is done
|
||||
for compatibility with `std::error_condition` as the next release is
|
||||
expected to improve interoperability with `<system_error>` even further.
|
||||
_Note that this does not affect_ `error_code::message`.
|
||||
|
||||
```
|
||||
constexpr bool failed() const noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns: :: `cat_\->failed( val_ )`.
|
||||
|
||||
WARNING: This member function is deprecated and will be removed. This is done
|
||||
for compatibility with `std::error_condition` as the next release is
|
||||
expected to improve interoperability with `<system_error>` even further.
|
||||
_Note that this does not affect_ `error_code::failed`.
|
||||
|
||||
### Nonmember functions
|
||||
|
||||
```
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
#ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||
#define BOOST_SYSTEM_CYGWIN_ERROR_HPP
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||
#endif
|
||||
|
||||
// This header is effectively empty for compiles on operating systems where
|
||||
// it is not applicable.
|
||||
|
||||
|
||||
@@ -48,4 +48,18 @@
|
||||
# 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))
|
||||
#endif
|
||||
|
||||
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
|
||||
|
||||
@@ -32,7 +32,6 @@ class error_condition
|
||||
private:
|
||||
|
||||
int val_;
|
||||
bool failed_;
|
||||
error_category const * cat_;
|
||||
|
||||
public:
|
||||
@@ -40,12 +39,12 @@ public:
|
||||
// constructors:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR error_condition() BOOST_NOEXCEPT:
|
||||
val_( 0 ), failed_( false ), cat_( &generic_category() )
|
||||
val_( 0 ), 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 )
|
||||
val_( val ), cat_( &cat )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,7 +59,6 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void assign( int val, const error_category & cat ) BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = val;
|
||||
failed_ = detail::failed_impl( val, cat );
|
||||
cat_ = &cat;
|
||||
}
|
||||
|
||||
@@ -75,7 +73,6 @@ public:
|
||||
BOOST_SYSTEM_CONSTEXPR void clear() BOOST_NOEXCEPT
|
||||
{
|
||||
val_ = 0;
|
||||
failed_ = false;
|
||||
cat_ = &generic_category();
|
||||
}
|
||||
|
||||
@@ -96,21 +93,21 @@ public:
|
||||
return cat_->message( value() );
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_DEPRECATED("this function is slated for removal") char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return cat_->message( value(), buffer, len );
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
BOOST_SYSTEM_DEPRECATED("this function is slated for removal") BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
{
|
||||
return failed_;
|
||||
return detail::failed_impl( val_, *cat_ );
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR explicit operator bool() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_;
|
||||
return val_ != 0;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -120,12 +117,12 @@ public:
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR operator unspecified_bool_type() const BOOST_NOEXCEPT // true if error
|
||||
{
|
||||
return failed_? unspecified_bool_true: 0;
|
||||
return val_ != 0? unspecified_bool_true: 0;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool operator!() const BOOST_NOEXCEPT // true if no error
|
||||
{
|
||||
return !failed_;
|
||||
return val_ == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -109,10 +109,10 @@ inline error_category const & generic_category() BOOST_NOEXCEPT
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
|
||||
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();
|
||||
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
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ inline error_category const & system_category() BOOST_NOEXCEPT
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
|
||||
inline const error_category & get_system_category() { return system_category(); }
|
||||
static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
|
||||
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
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
case ERROR_WRITE_FAULT_: return io_error;
|
||||
case ERROR_WRITE_PROTECT_: return permission_denied;
|
||||
|
||||
case WSAEACCES_: return permission_denied;
|
||||
case WSAEACCES_: return permission_denied;
|
||||
case WSAEADDRINUSE_: return address_in_use;
|
||||
case WSAEADDRNOTAVAIL_: return address_not_available;
|
||||
case WSAEAFNOSUPPORT_: return address_family_not_supported;
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
#ifndef BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||
#define BOOST_SYSTEM_LINUX_ERROR_HPP
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||
#endif
|
||||
|
||||
// This header is effectively empty for compiles on operating systems where
|
||||
// it is not applicable.
|
||||
|
||||
|
||||
@@ -10,6 +10,13 @@
|
||||
#ifndef BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
||||
#define BOOST_SYSTEM_WINDOWS_ERROR_HPP
|
||||
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_ALLOW_DEPRECATED_HEADERS)
|
||||
BOOST_PRAGMA_MESSAGE("This header is deprecated and is slated for removal."
|
||||
" If you want it retained, please open an issue in github.com/boostorg/system.")
|
||||
#endif
|
||||
|
||||
// This header is effectively empty for compiles on operating systems where
|
||||
// it is not applicable.
|
||||
|
||||
|
||||
@@ -85,3 +85,7 @@ run generic_category_test2.cpp ;
|
||||
run generic_category_test3.cpp ;
|
||||
run system_category_test2.cpp ;
|
||||
run system_category_test3.cpp ;
|
||||
|
||||
run windows_error_test.cpp ;
|
||||
run cygwin_error_test.cpp ;
|
||||
run linux_error_test.cpp ;
|
||||
|
||||
29
test/cygwin_error_test.cpp
Normal file
29
test/cygwin_error_test.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/cygwin_error.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(__CYGWIN__)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, __CYGWIN__ is not defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
sys::error_code ec = sys::cygwin_error::no_package;
|
||||
|
||||
BOOST_TEST_EQ( ec, sys::cygwin_error::no_package );
|
||||
BOOST_TEST_EQ( ec, sys::error_code( ENOPKG, sys::system_category() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -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>
|
||||
@@ -294,29 +291,7 @@ int main( int, char ** )
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
||||
std::cout << "Cygwin tests...\n";
|
||||
ec = cygwin_error::no_package;
|
||||
BOOST_TEST( ec == cygwin_error::no_package );
|
||||
BOOST_TEST( ec == error_code( ENOPKG, system_category() ) );
|
||||
BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category() ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
||||
|
||||
# elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||
|
||||
std::cout << "Linux tests...\n";
|
||||
ec = linux_error::dot_dot_error;
|
||||
BOOST_TEST( ec == linux_error::dot_dot_error );
|
||||
BOOST_TEST( ec == error_code( EDOTDOT, system_category() ) );
|
||||
BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category() ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category() );
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -120,18 +120,30 @@ template<class Ec> void test()
|
||||
ec.assign( 0, generic_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
template<class Ec> void test2()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
ec.assign( 200, http_category() );
|
||||
TEST_NOT_FAILED( ec );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
ec = Ec( 404, http_category() );
|
||||
TEST_FAILED( ec );
|
||||
}
|
||||
|
||||
template<class Ec> void test3()
|
||||
{
|
||||
Ec ec( 0, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
|
||||
ec.assign( 200, http_category() );
|
||||
BOOST_TEST( !ec.failed() );
|
||||
|
||||
ec = Ec( 404, http_category() );
|
||||
BOOST_TEST( ec.failed() );
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -147,7 +159,9 @@ int main()
|
||||
BOOST_TEST( http_category().failed( 404 ) );
|
||||
|
||||
test<error_code>();
|
||||
test2<error_code>();
|
||||
test<error_condition>();
|
||||
test3<error_condition>();
|
||||
|
||||
{
|
||||
error_condition ec( errc::success );
|
||||
|
||||
29
test/linux_error_test.cpp
Normal file
29
test/linux_error_test.cpp
Normal 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
|
||||
31
test/windows_error_test.cpp
Normal file
31
test/windows_error_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/windows_error.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if !defined(BOOST_WINDOWS_API)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "Skipping test, BOOST_WINDOWS_API is not defined" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <windows.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
namespace sys = boost::system;
|
||||
|
||||
sys::error_code ec = sys::windows_error::invalid_function;
|
||||
|
||||
BOOST_TEST_EQ( ec, sys::windows_error::invalid_function );
|
||||
BOOST_TEST_EQ( ec, sys::error_code( ERROR_INVALID_FUNCTION, sys::system_category() ) );
|
||||
BOOST_TEST( ec == make_error_condition( sys::errc::function_not_supported ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user