forked from boostorg/system
Move make_ functions for errc to errc.hpp
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/system_category.hpp>
|
||||
#include <boost/system/detail/enable_if.hpp>
|
||||
#include <boost/system/is_error_code_enum.hpp>
|
||||
|
@ -11,5 +11,39 @@
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/generic_category.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
// make_* functions for errc::errc_t
|
||||
|
||||
namespace errc
|
||||
{
|
||||
|
||||
// explicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_code( e, generic_category() );
|
||||
}
|
||||
|
||||
// implicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_condition( e, generic_category() );
|
||||
}
|
||||
|
||||
} // namespace errc
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_ERRC_HPP_INCLUDED
|
||||
|
@ -10,17 +10,13 @@
|
||||
//
|
||||
// See library home page at http://www.boost.org/libs/system
|
||||
|
||||
#include <boost/system/is_error_code_enum.hpp>
|
||||
#include <boost/system/is_error_condition_enum.hpp>
|
||||
#include <boost/system/detail/errc.hpp>
|
||||
#include <boost/system/detail/error_category.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/error_category.hpp>
|
||||
#include <boost/system/error_condition.hpp>
|
||||
#include <boost/system/errc.hpp>
|
||||
#include <boost/system/detail/generic_category.hpp>
|
||||
#include <boost/system/detail/system_category.hpp>
|
||||
#include <boost/system/detail/enable_if.hpp>
|
||||
#include <boost/system/detail/error_condition.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/throws.hpp>
|
||||
#include <boost/system/detail/error_category_impl.hpp>
|
||||
#include <boost/system/api_config.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
@ -75,25 +71,6 @@ inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BO
|
||||
return !( lhs == rhs );
|
||||
}
|
||||
|
||||
// make_* functions for errc::errc_t
|
||||
|
||||
namespace errc
|
||||
{
|
||||
|
||||
// explicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_code( e, generic_category() );
|
||||
}
|
||||
|
||||
// implicit conversion:
|
||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||
{
|
||||
return error_condition( e, generic_category() );
|
||||
}
|
||||
|
||||
} // namespace errc
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
@ -79,3 +79,4 @@ run is_error_condition_enum_test.cpp ;
|
||||
run errc_test.cpp ;
|
||||
run error_category_test2.cpp ;
|
||||
run error_condition_test.cpp ;
|
||||
run error_condition_test2.cpp ;
|
||||
|
25
test/error_condition_test2.cpp
Normal file
25
test/error_condition_test2.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_condition.hpp>
|
||||
#include <boost/system/errc.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
sys::error_condition en( sys::errc::no_such_file_or_directory );
|
||||
|
||||
BOOST_TEST_EQ( en.value(), ENOENT );
|
||||
|
||||
BOOST_TEST( en );
|
||||
BOOST_TEST( !!en );
|
||||
|
||||
BOOST_TEST( en == make_error_condition( sys::errc::no_such_file_or_directory ) );
|
||||
|
||||
BOOST_TEST( en.category() == sys::error_condition().category() );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user