forked from boostorg/system
Extract is_error_code_enum, is_error_condition_enum into their own headers
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
//
|
||||
// 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/api_config.hpp>
|
||||
#include <boost/system/detail/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
@ -40,18 +42,6 @@ class error_code; // values defined by the operating system
|
||||
class error_condition; // portable generic values defined below, but ultimately
|
||||
// based on the POSIX standard
|
||||
|
||||
// "Concept" helpers
|
||||
|
||||
template<class T> struct is_error_code_enum
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template<class T> struct is_error_condition_enum
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
// Generic error_conditions
|
||||
|
||||
namespace errc
|
||||
|
30
include/boost/system/is_error_code_enum.hpp
Normal file
30
include/boost/system/is_error_code_enum.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
||||
|
||||
// Copyright Beman Dawes 2006, 2007
|
||||
// Copyright Christoper Kohlhoff 2007
|
||||
// Copyright Peter Dimov 2017, 2018
|
||||
//
|
||||
// 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
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
class error_code;
|
||||
|
||||
template<class T> struct is_error_code_enum
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED
|
30
include/boost/system/is_error_condition_enum.hpp
Normal file
30
include/boost/system/is_error_condition_enum.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
||||
#define BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
||||
|
||||
// Copyright Beman Dawes 2006, 2007
|
||||
// Copyright Christoper Kohlhoff 2007
|
||||
// Copyright Peter Dimov 2017, 2018
|
||||
//
|
||||
// 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
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace system
|
||||
{
|
||||
|
||||
class error_condition;
|
||||
|
||||
template<class T> struct is_error_condition_enum
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
} // namespace system
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED
|
@ -73,3 +73,6 @@ lib std_single_instance_lib2 : std_single_instance_2.cpp : <link>shared:<define>
|
||||
system-run std_single_instance_test.cpp std_single_instance_1.cpp std_single_instance_2.cpp ;
|
||||
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>static : std_single_instance_lib_static ;
|
||||
run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : <link>shared <define>STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ;
|
||||
|
||||
run is_error_code_enum_test.cpp ;
|
||||
run is_error_condition_enum_test.cpp ;
|
||||
|
41
test/is_error_code_enum_test.cpp
Normal file
41
test/is_error_code_enum_test.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/is_error_code_enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
enum error
|
||||
{
|
||||
success = 0,
|
||||
e1,
|
||||
e2,
|
||||
e3
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_code_enum< ::error >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
boost::system::error_code make_error_code( ::error e );
|
||||
|
||||
enum not_error
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( boost::system::is_error_code_enum< ::error >::value );
|
||||
BOOST_TEST( !boost::system::is_error_code_enum< ::not_error >::value );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
40
test/is_error_condition_enum_test.cpp
Normal file
40
test/is_error_condition_enum_test.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
// Copyright 2020 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/is_error_condition_enum.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
enum condition
|
||||
{
|
||||
c1 = 1,
|
||||
c2,
|
||||
c3
|
||||
};
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace system
|
||||
{
|
||||
|
||||
template<> struct is_error_condition_enum< ::condition >
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
boost::system::error_condition make_error_condition( ::condition e );
|
||||
|
||||
enum not_condition
|
||||
{
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( boost::system::is_error_condition_enum< ::condition >::value );
|
||||
BOOST_TEST( !boost::system::is_error_condition_enum< ::not_condition >::value );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Reference in New Issue
Block a user