mirror of
https://github.com/boostorg/system.git
synced 2026-06-12 12:11:19 +02:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b9c26b9fa0 | |||
| 2e2430c4fa | |||
| 4b1caad727 | |||
| 5b96abbaa8 | |||
| 2e1c800d82 | |||
| 04a79d710f | |||
| 5700936367 | |||
| 86b031cab9 | |||
| 204e65f725 | |||
| 01ce081470 | |||
| 8c9ceba775 |
@@ -144,6 +144,10 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.1
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
|
||||
+1
-9
@@ -22,20 +22,12 @@ environment:
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 64
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
|
||||
@@ -12,124 +12,101 @@
|
||||
|
||||
#include <boost/system/is_error_condition_enum.hpp>
|
||||
#include <boost/system/detail/cerrno.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
#define BOOST_SYSTEM_ENUMERATE_ERRC(F, G) \
|
||||
F(success, 0) \
|
||||
F(address_family_not_supported, EAFNOSUPPORT) \
|
||||
F(address_in_use, EADDRINUSE) \
|
||||
F(address_not_available, EADDRNOTAVAIL) \
|
||||
F(already_connected, EISCONN) \
|
||||
F(argument_list_too_long, E2BIG) \
|
||||
F(argument_out_of_domain, EDOM) \
|
||||
F(bad_address, EFAULT) \
|
||||
F(bad_file_descriptor, EBADF) \
|
||||
F(bad_message, EBADMSG) \
|
||||
F(broken_pipe, EPIPE) \
|
||||
F(connection_aborted, ECONNABORTED) \
|
||||
F(connection_already_in_progress, EALREADY) \
|
||||
F(connection_refused, ECONNREFUSED) \
|
||||
F(connection_reset, ECONNRESET) \
|
||||
F(cross_device_link, EXDEV) \
|
||||
F(destination_address_required, EDESTADDRREQ) \
|
||||
F(device_or_resource_busy, EBUSY) \
|
||||
F(directory_not_empty, ENOTEMPTY) \
|
||||
F(executable_format_error, ENOEXEC) \
|
||||
F(file_exists, EEXIST) \
|
||||
F(file_too_large, EFBIG) \
|
||||
F(filename_too_long, ENAMETOOLONG) \
|
||||
F(function_not_supported, ENOSYS) \
|
||||
F(host_unreachable, EHOSTUNREACH) \
|
||||
F(identifier_removed, EIDRM) \
|
||||
F(illegal_byte_sequence, EILSEQ) \
|
||||
F(inappropriate_io_control_operation, ENOTTY) \
|
||||
F(interrupted, EINTR) \
|
||||
F(invalid_argument, EINVAL) \
|
||||
F(invalid_seek, ESPIPE) \
|
||||
F(io_error, EIO) \
|
||||
F(is_a_directory, EISDIR) \
|
||||
F(message_size, EMSGSIZE) \
|
||||
F(network_down, ENETDOWN) \
|
||||
F(network_reset, ENETRESET) \
|
||||
F(network_unreachable, ENETUNREACH) \
|
||||
F(no_buffer_space, ENOBUFS) \
|
||||
F(no_child_process, ECHILD) \
|
||||
F(no_link, ENOLINK) \
|
||||
F(no_lock_available, ENOLCK) \
|
||||
F(no_message_available, ENODATA) \
|
||||
F(no_message, ENOMSG) \
|
||||
F(no_protocol_option, ENOPROTOOPT) \
|
||||
F(no_space_on_device, ENOSPC) \
|
||||
F(no_stream_resources, ENOSR) \
|
||||
F(no_such_device_or_address, ENXIO) \
|
||||
F(no_such_device, ENODEV) \
|
||||
F(no_such_file_or_directory, ENOENT) \
|
||||
F(no_such_process, ESRCH) \
|
||||
F(not_a_directory, ENOTDIR) \
|
||||
F(not_a_socket, ENOTSOCK) \
|
||||
F(not_a_stream, ENOSTR) \
|
||||
F(not_connected, ENOTCONN) \
|
||||
F(not_enough_memory, ENOMEM) \
|
||||
F(not_supported, ENOTSUP) \
|
||||
F(operation_canceled, ECANCELED) \
|
||||
F(operation_in_progress, EINPROGRESS) \
|
||||
F(operation_not_permitted, EPERM) \
|
||||
F(operation_not_supported, EOPNOTSUPP) \
|
||||
F(operation_would_block, EWOULDBLOCK) \
|
||||
F(owner_dead, EOWNERDEAD) \
|
||||
F(permission_denied, EACCES) \
|
||||
F(protocol_error, EPROTO) \
|
||||
F(protocol_not_supported, EPROTONOSUPPORT) \
|
||||
F(read_only_file_system, EROFS) \
|
||||
F(resource_deadlock_would_occur, EDEADLK) \
|
||||
F(resource_unavailable_try_again, EAGAIN) \
|
||||
F(result_out_of_range, ERANGE) \
|
||||
F(state_not_recoverable, ENOTRECOVERABLE) \
|
||||
F(stream_timeout, ETIME) \
|
||||
F(text_file_busy, ETXTBSY) \
|
||||
F(timed_out, ETIMEDOUT) \
|
||||
F(too_many_files_open_in_system, ENFILE) \
|
||||
F(too_many_files_open, EMFILE) \
|
||||
F(too_many_links, EMLINK) \
|
||||
F(too_many_symbolic_link_levels, ELOOP) \
|
||||
F(value_too_large, EOVERFLOW) \
|
||||
G(wrong_protocol_type, EPROTOTYPE)
|
||||
|
||||
namespace errc
|
||||
{
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_SYSTEM_ENABLE_DEPRECATED)
|
||||
enum class errc_t
|
||||
#else
|
||||
enum errc_t
|
||||
#endif
|
||||
{
|
||||
|
||||
#define BOOST_SYSTEM_DEFINE_ERRC(x, y) x = y,
|
||||
#define BOOST_SYSTEM_DEFINE_ERRC2(x, y) x = y
|
||||
BOOST_SYSTEM_ENUMERATE_ERRC(BOOST_SYSTEM_DEFINE_ERRC, BOOST_SYSTEM_DEFINE_ERRC2)
|
||||
#undef BOOST_SYSTEM_DEFINE_ERRC
|
||||
#undef BOOST_SYSTEM_DEFINE_ERRC2
|
||||
|
||||
}; // enum errc_t
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_SYSTEM_ENABLE_DEPRECATED)
|
||||
|
||||
#define BOOST_SYSTEM_SURFACE_ERRC(x, y) BOOST_CONSTEXPR_OR_CONST errc_t x = errc_t::x;
|
||||
BOOST_SYSTEM_ENUMERATE_ERRC(BOOST_SYSTEM_SURFACE_ERRC, BOOST_SYSTEM_SURFACE_ERRC)
|
||||
#undef BOOST_SYSTEM_SURFACE_ERRC
|
||||
|
||||
#endif
|
||||
success = 0,
|
||||
address_family_not_supported = EAFNOSUPPORT,
|
||||
address_in_use = EADDRINUSE,
|
||||
address_not_available = EADDRNOTAVAIL,
|
||||
already_connected = EISCONN,
|
||||
argument_list_too_long = E2BIG,
|
||||
argument_out_of_domain = EDOM,
|
||||
bad_address = EFAULT,
|
||||
bad_file_descriptor = EBADF,
|
||||
bad_message = EBADMSG,
|
||||
broken_pipe = EPIPE,
|
||||
connection_aborted = ECONNABORTED,
|
||||
connection_already_in_progress = EALREADY,
|
||||
connection_refused = ECONNREFUSED,
|
||||
connection_reset = ECONNRESET,
|
||||
cross_device_link = EXDEV,
|
||||
destination_address_required = EDESTADDRREQ,
|
||||
device_or_resource_busy = EBUSY,
|
||||
directory_not_empty = ENOTEMPTY,
|
||||
executable_format_error = ENOEXEC,
|
||||
file_exists = EEXIST,
|
||||
file_too_large = EFBIG,
|
||||
filename_too_long = ENAMETOOLONG,
|
||||
function_not_supported = ENOSYS,
|
||||
host_unreachable = EHOSTUNREACH,
|
||||
identifier_removed = EIDRM,
|
||||
illegal_byte_sequence = EILSEQ,
|
||||
inappropriate_io_control_operation = ENOTTY,
|
||||
interrupted = EINTR,
|
||||
invalid_argument = EINVAL,
|
||||
invalid_seek = ESPIPE,
|
||||
io_error = EIO,
|
||||
is_a_directory = EISDIR,
|
||||
message_size = EMSGSIZE,
|
||||
network_down = ENETDOWN,
|
||||
network_reset = ENETRESET,
|
||||
network_unreachable = ENETUNREACH,
|
||||
no_buffer_space = ENOBUFS,
|
||||
no_child_process = ECHILD,
|
||||
no_link = ENOLINK,
|
||||
no_lock_available = ENOLCK,
|
||||
no_message_available = ENODATA,
|
||||
no_message = ENOMSG,
|
||||
no_protocol_option = ENOPROTOOPT,
|
||||
no_space_on_device = ENOSPC,
|
||||
no_stream_resources = ENOSR,
|
||||
no_such_device_or_address = ENXIO,
|
||||
no_such_device = ENODEV,
|
||||
no_such_file_or_directory = ENOENT,
|
||||
no_such_process = ESRCH,
|
||||
not_a_directory = ENOTDIR,
|
||||
not_a_socket = ENOTSOCK,
|
||||
not_a_stream = ENOSTR,
|
||||
not_connected = ENOTCONN,
|
||||
not_enough_memory = ENOMEM,
|
||||
not_supported = ENOTSUP,
|
||||
operation_canceled = ECANCELED,
|
||||
operation_in_progress = EINPROGRESS,
|
||||
operation_not_permitted = EPERM,
|
||||
operation_not_supported = EOPNOTSUPP,
|
||||
operation_would_block = EWOULDBLOCK,
|
||||
owner_dead = EOWNERDEAD,
|
||||
permission_denied = EACCES,
|
||||
protocol_error = EPROTO,
|
||||
protocol_not_supported = EPROTONOSUPPORT,
|
||||
read_only_file_system = EROFS,
|
||||
resource_deadlock_would_occur = EDEADLK,
|
||||
resource_unavailable_try_again = EAGAIN,
|
||||
result_out_of_range = ERANGE,
|
||||
state_not_recoverable = ENOTRECOVERABLE,
|
||||
stream_timeout = ETIME,
|
||||
text_file_busy = ETXTBSY,
|
||||
timed_out = ETIMEDOUT,
|
||||
too_many_files_open_in_system = ENFILE,
|
||||
too_many_files_open = EMFILE,
|
||||
too_many_links = EMLINK,
|
||||
too_many_symbolic_link_levels = ELOOP,
|
||||
value_too_large = EOVERFLOW,
|
||||
wrong_protocol_type = EPROTOTYPE
|
||||
};
|
||||
|
||||
} // namespace errc
|
||||
|
||||
#undef BOOST_SYSTEM_ENUMERATE_ERRC
|
||||
|
||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||
|
||||
namespace posix = errc;
|
||||
@@ -143,6 +120,7 @@ template<> struct is_error_condition_enum<errc::errc_t>
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
||||
|
||||
@@ -83,6 +83,28 @@ private:
|
||||
// >3: pointer to source_location, failed_ in lsb
|
||||
boost::uintptr_t lc_flags_;
|
||||
|
||||
private:
|
||||
|
||||
char const* category_name() const BOOST_NOEXCEPT
|
||||
{
|
||||
// return category().name();
|
||||
|
||||
if( lc_flags_ == 0 )
|
||||
{
|
||||
// must match detail::system_error_category::name()
|
||||
return "system";
|
||||
}
|
||||
else if( lc_flags_ == 1 )
|
||||
{
|
||||
// must match detail::interop_error_category::name()
|
||||
return "std:unknown";
|
||||
}
|
||||
else
|
||||
{
|
||||
return d1_.cat_->name();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
@@ -188,7 +210,11 @@ public:
|
||||
#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
|
||||
|
||||
unsigned cv = static_cast<unsigned>( ec.value() );
|
||||
unsigned ch = static_cast<unsigned>( reinterpret_cast<boost::uintptr_t>( &ec.category() ) % 2097143 ); // 2^21-9, prime
|
||||
|
||||
return static_cast<int>( cv + 1000 * ch );
|
||||
#else
|
||||
|
||||
return -1;
|
||||
@@ -230,7 +256,14 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
return category().message( value() );
|
||||
if( lc_flags_ == 0 )
|
||||
{
|
||||
return detail::system_error_category_message( value() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return category().message( value() );
|
||||
}
|
||||
}
|
||||
|
||||
char const * message( char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
@@ -238,23 +271,33 @@ public:
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
if( lc_flags_ == 1 )
|
||||
{
|
||||
std::error_code const& ec = *reinterpret_cast<std::error_code const*>( d2_ );
|
||||
|
||||
#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( ... )
|
||||
{
|
||||
detail::snprintf( buffer, len, "No message text available for error std:%s:%d", ec.category().name(), ec.value() );
|
||||
return buffer;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return category().message( value(), buffer, len );
|
||||
if( lc_flags_ == 0 )
|
||||
{
|
||||
return detail::system_error_category_message( value(), buffer, len );
|
||||
}
|
||||
else
|
||||
{
|
||||
return category().message( value(), buffer, len );
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR bool failed() const BOOST_NOEXCEPT
|
||||
@@ -594,7 +637,7 @@ public:
|
||||
else
|
||||
#endif
|
||||
{
|
||||
std::string r = category().name();
|
||||
std::string r = category_name();
|
||||
detail::append_int( r, value() );
|
||||
return r;
|
||||
}
|
||||
@@ -604,7 +647,7 @@ public:
|
||||
inline friend std::basic_ostream<Ch, Tr>&
|
||||
operator<< (std::basic_ostream<Ch, Tr>& os, error_code const & ec)
|
||||
{
|
||||
return os << ec.to_string();
|
||||
return os << ec.to_string().c_str();
|
||||
}
|
||||
|
||||
std::string what() const
|
||||
|
||||
@@ -84,7 +84,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_( static_cast<int>( e ) ), cat_( 0 )
|
||||
val_( e ), cat_( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace system
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline errc::errc_t system_category_condition_win32_( int ev ) BOOST_NOEXCEPT
|
||||
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
{
|
||||
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
||||
// We want to map the common Win32 errors to their equivalent error condition,
|
||||
@@ -138,15 +138,10 @@ inline errc::errc_t system_category_condition_win32_( int ev ) BOOST_NOEXCEPT
|
||||
case WSAETIMEDOUT_: return timed_out;
|
||||
case WSAEWOULDBLOCK_: return operation_would_block;
|
||||
|
||||
default: return static_cast<errc::errc_t>( -1 );
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||
{
|
||||
return static_cast<int>( system_category_condition_win32_( ev ) );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace system
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/system_category.hpp>
|
||||
#include <boost/system/detail/system_category_message.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/api_config.hpp>
|
||||
|
||||
@@ -22,7 +23,6 @@
|
||||
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#include <boost/system/detail/system_category_message_win32.hpp>
|
||||
#include <boost/system/detail/system_category_condition_win32.hpp>
|
||||
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
@@ -39,35 +39,23 @@ inline boost::system::error_condition boost::system::detail::system_error_catego
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||
{
|
||||
return system_category_message_win32( ev );
|
||||
}
|
||||
|
||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return system_category_message_win32( ev, buffer, len );
|
||||
}
|
||||
|
||||
#else // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#include <boost/system/detail/generic_category_message.hpp>
|
||||
|
||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return error_condition( boost::system::detail::generic_value_tag( ev ) );
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||
{
|
||||
return generic_error_category_message( ev );
|
||||
return system_error_category_message( ev );
|
||||
}
|
||||
|
||||
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
||||
{
|
||||
return generic_error_category_message( ev, buffer, len );
|
||||
return system_error_category_message( ev, buffer, len );
|
||||
}
|
||||
|
||||
#endif // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||
|
||||
// Implementation of system_error_category_message
|
||||
//
|
||||
// Copyright 2018, 2022 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/api_config.hpp>
|
||||
|
||||
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
||||
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#include <boost/system/detail/system_category_message_win32.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline std::string system_error_category_message( int ev )
|
||||
{
|
||||
return system_category_message_win32( ev );
|
||||
}
|
||||
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
{
|
||||
return system_category_message_win32( ev, buffer, len );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#else // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#include <boost/system/detail/generic_category_message.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline std::string system_error_category_message( int ev )
|
||||
{
|
||||
return generic_error_category_message( ev );
|
||||
}
|
||||
|
||||
inline char const * system_error_category_message( int ev, char * buffer, std::size_t len ) BOOST_NOEXCEPT
|
||||
{
|
||||
return generic_error_category_message( ev, buffer, len );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
#endif // #if defined(BOOST_WINDOWS_API)
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_MESSAGE_HPP_INCLUDED
|
||||
@@ -32,13 +32,13 @@ namespace errc
|
||||
// explicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_code( static_cast<int>( e ), generic_category() );
|
||||
return error_code( e, generic_category() );
|
||||
}
|
||||
|
||||
// implicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_condition( static_cast<int>( e ), generic_category() );
|
||||
return error_condition( e, generic_category() );
|
||||
}
|
||||
|
||||
} // namespace errc
|
||||
|
||||
@@ -10,13 +10,6 @@
|
||||
#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.
|
||||
|
||||
|
||||
@@ -39,6 +39,15 @@ constexpr in_place_value_t in_place_value{};
|
||||
using in_place_error_t = variant2::in_place_index_t<1>;
|
||||
constexpr in_place_error_t in_place_error{};
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> using remove_cvref = typename std::remove_cv< typename std::remove_reference<T>::type >::type;
|
||||
|
||||
template<class... T> using is_errc_t = std::is_same<mp11::mp_list<remove_cvref<T>...>, mp11::mp_list<errc::errc_t>>;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// result
|
||||
|
||||
template<class T, class E = error_code> class result
|
||||
@@ -65,6 +74,7 @@ public:
|
||||
// implicit, value
|
||||
template<class A = T, typename std::enable_if<
|
||||
std::is_convertible<A, T>::value &&
|
||||
!(detail::is_errc_t<A>::value && std::is_arithmetic<T>::value) &&
|
||||
!std::is_constructible<E, A>::value, int>::type = 0>
|
||||
constexpr result( A&& a )
|
||||
noexcept( std::is_nothrow_constructible<T, A>::value )
|
||||
@@ -85,6 +95,7 @@ public:
|
||||
// explicit, value
|
||||
template<class... A, class En = typename std::enable_if<
|
||||
std::is_constructible<T, A...>::value &&
|
||||
!(detail::is_errc_t<A...>::value && std::is_arithmetic<T>::value) &&
|
||||
!std::is_constructible<E, A...>::value
|
||||
>::type>
|
||||
explicit constexpr result( A&&... a )
|
||||
|
||||
@@ -112,6 +112,8 @@ boost_test(TYPE run SOURCES system_error_test3.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES std_interop_test11.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES ec_wstream_test.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
|
||||
@@ -134,6 +134,8 @@ run system_error_test3.cpp ;
|
||||
|
||||
run std_interop_test11.cpp ;
|
||||
|
||||
run ec_wstream_test.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
@@ -154,3 +156,4 @@ run result_eq.cpp : : : $(CPP11) ;
|
||||
run result_range_for.cpp : : : $(CPP11) ;
|
||||
run result_value_construct2.cpp : : : $(CPP11) ;
|
||||
run result_error_construct2.cpp : : : $(CPP11) ;
|
||||
run result_errc_construct.cpp : : : $(CPP11) ;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::wostringstream os;
|
||||
os << sys::error_code();
|
||||
|
||||
BOOST_TEST( os.str() == L"system:0" );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -165,7 +165,7 @@ int main( int, char ** )
|
||||
econd = ec.default_error_condition();
|
||||
BOOST_TEST( econd.value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( econd.category() == generic_category() );
|
||||
BOOST_TEST( econd == error_condition( static_cast<int>(errc::permission_denied), generic_category() ) );
|
||||
BOOST_TEST( econd == error_condition( errc::permission_denied, generic_category() ) );
|
||||
BOOST_TEST( econd == errc::permission_denied );
|
||||
BOOST_TEST( errc::permission_denied == econd );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
@@ -244,35 +244,35 @@ int main( int, char ** )
|
||||
ec = error_code( ERROR_ACCESS_DENIED, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the second entry in the decoder table:
|
||||
ec = error_code( ERROR_ALREADY_EXISTS, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS );
|
||||
BOOST_TEST( ec == errc::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::file_exists) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the third entry in the decoder table:
|
||||
ec = error_code( ERROR_BAD_UNIT, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_BAD_UNIT );
|
||||
BOOST_TEST( ec == errc::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::no_such_device) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the last non-Winsock entry in the decoder table:
|
||||
ec = error_code( ERROR_WRITE_PROTECT, system_category() );
|
||||
BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test the last Winsock entry in the decoder table:
|
||||
ec = error_code( WSAEWOULDBLOCK, system_category() );
|
||||
BOOST_TEST( ec.value() == WSAEWOULDBLOCK );
|
||||
BOOST_TEST( ec == errc::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::operation_would_block) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
// test not-in-table condition:
|
||||
@@ -285,11 +285,11 @@ int main( int, char ** )
|
||||
|
||||
std::cout << "POSIX tests...\n";
|
||||
ec = error_code( EACCES, system_category() );
|
||||
BOOST_TEST( ec == error_code( static_cast<int>(errc::permission_denied), system_category() ) );
|
||||
BOOST_TEST( error_code( static_cast<int>(errc::permission_denied), system_category() ) == ec );
|
||||
BOOST_TEST( ec == error_code( errc::permission_denied, system_category() ) );
|
||||
BOOST_TEST( error_code( errc::permission_denied, system_category() ) == ec );
|
||||
BOOST_TEST( ec == errc::permission_denied );
|
||||
BOOST_TEST( errc::permission_denied == ec );
|
||||
BOOST_TEST( ec.default_error_condition().value() == static_cast<int>(errc::permission_denied) );
|
||||
BOOST_TEST( ec.default_error_condition().value() == errc::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == generic_category() );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace boost
|
||||
boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return ev == boo_boo
|
||||
? boost::system::error_condition( static_cast<int>( boost::system::errc::io_error ),
|
||||
? boost::system::error_condition( boost::system::errc::io_error,
|
||||
boost::system::generic_category() )
|
||||
: boost::system::error_condition( ev,
|
||||
boost::lib3::lib3_error_category );
|
||||
@@ -180,7 +180,7 @@ namespace lib4
|
||||
boost::system::error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return ev == boo_boo.value()
|
||||
? boost::system::error_condition( static_cast<int>( boost::system::errc::io_error ),
|
||||
? boost::system::error_condition( boost::system::errc::io_error,
|
||||
boost::system::generic_category() )
|
||||
: boost::system::error_condition( ev, lib4::lib4_error_category );
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ struct foo
|
||||
foo()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
BOOST_TEST( ec != boost::system::errc::permission_denied );
|
||||
BOOST_TEST_NE( ec, boost::system::errc::permission_denied );
|
||||
}
|
||||
} f;
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/result.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<int>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<int>, errc::errc_t>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<double>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<double>, errc::errc_t>));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_convertible<errc::errc_t, result<bool>>));
|
||||
BOOST_TEST_TRAIT_FALSE((std::is_constructible<result<bool>, errc::errc_t>));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user