mirror of
https://github.com/boostorg/system.git
synced 2025-07-29 20:17:13 +02:00
Enable error_code construction from enums specializing std::is_error_code_enum. Fixes #70.
This commit is contained in:
@ -107,8 +107,12 @@ public:
|
||||
}
|
||||
|
||||
template<class ErrorCodeEnum> BOOST_SYSTEM_CONSTEXPR error_code( ErrorCodeEnum e,
|
||||
typename detail::enable_if<is_error_code_enum<ErrorCodeEnum>::value>::type* = 0 ) BOOST_NOEXCEPT:
|
||||
d1_(), lc_flags_( 0 )
|
||||
typename detail::enable_if<
|
||||
is_error_code_enum<ErrorCodeEnum>::value
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|| std::is_error_code_enum<ErrorCodeEnum>::value
|
||||
#endif
|
||||
>::type* = 0 ) BOOST_NOEXCEPT: d1_(), lc_flags_( 0 )
|
||||
{
|
||||
*this = make_error_code( e );
|
||||
}
|
||||
|
@ -110,6 +110,8 @@ boost_test(TYPE run SOURCES ec_location_test2.cpp)
|
||||
boost_test(TYPE run SOURCES ec_what_test.cpp)
|
||||
boost_test(TYPE run SOURCES system_error_test3.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES std_interop_test11.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
|
@ -132,6 +132,8 @@ run ec_location_test2.cpp ;
|
||||
run ec_what_test.cpp ;
|
||||
run system_error_test3.cpp ;
|
||||
|
||||
run std_interop_test11.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
42
test/std_interop_test11.cpp
Normal file
42
test/std_interop_test11.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
// 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 ec = std::io_errc::stream;
|
||||
|
||||
BOOST_TEST( ec == std::io_errc::stream );
|
||||
BOOST_TEST_NOT( ec != std::io_errc::stream );
|
||||
|
||||
ec.clear();
|
||||
|
||||
BOOST_TEST_NOT( ec == std::io_errc::stream );
|
||||
BOOST_TEST( ec != std::io_errc::stream );
|
||||
|
||||
ec = std::io_errc::stream;
|
||||
|
||||
BOOST_TEST( ec == std::io_errc::stream );
|
||||
BOOST_TEST_NOT( ec != std::io_errc::stream );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user