mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
Add an errc::make_error_code overload taking a source location
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
#include <boost/system/detail/generic_category.hpp>
|
#include <boost/system/detail/generic_category.hpp>
|
||||||
#include <boost/system/detail/error_category_impl.hpp>
|
#include <boost/system/detail/error_category_impl.hpp>
|
||||||
#include <boost/system/detail/config.hpp>
|
#include <boost/system/detail/config.hpp>
|
||||||
|
#include <boost/assert/source_location.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@ -35,6 +36,12 @@ BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXC
|
|||||||
return error_code( e, generic_category() );
|
return error_code( e, generic_category() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// explicit conversion:
|
||||||
|
inline error_code make_error_code( errc_t e, boost::source_location const* loc ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return error_code( e, generic_category(), loc );
|
||||||
|
}
|
||||||
|
|
||||||
// implicit conversion:
|
// implicit conversion:
|
||||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
|
@ -116,6 +116,8 @@ boost_test(TYPE run SOURCES ec_wstream_test.cpp)
|
|||||||
|
|
||||||
boost_test(TYPE run SOURCES std_interop_test12.cpp)
|
boost_test(TYPE run SOURCES std_interop_test12.cpp)
|
||||||
|
|
||||||
|
boost_test(TYPE run SOURCES errc_test4.cpp)
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||||
|
@ -140,6 +140,8 @@ run ec_wstream_test.cpp ;
|
|||||||
|
|
||||||
run std_interop_test12.cpp ;
|
run std_interop_test12.cpp ;
|
||||||
|
|
||||||
|
run errc_test4.cpp ;
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
import ../../config/checks/config : requires ;
|
import ../../config/checks/config : requires ;
|
||||||
|
17
test/errc_test4.cpp
Normal file
17
test/errc_test4.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2022 Peter Dimov.
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/system/errc.hpp>
|
||||||
|
#include <boost/assert/source_location.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
|
||||||
|
|
||||||
|
BOOST_TEST( make_error_code( boost::system::errc::no_such_file_or_directory, &loc ).has_location() );
|
||||||
|
BOOST_TEST_EQ( make_error_code( boost::system::errc::no_such_file_or_directory, &loc ).location().to_string(), loc.to_string() );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user