diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index ed8584e..9914391 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -10,6 +10,8 @@ // // See library home page at http://www.boost.org/libs/system +#include +#include #include #include #include @@ -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 struct is_error_code_enum -{ - static const bool value = false; -}; - -template struct is_error_condition_enum -{ - static const bool value = false; -}; - // Generic error_conditions namespace errc diff --git a/include/boost/system/is_error_code_enum.hpp b/include/boost/system/is_error_code_enum.hpp new file mode 100644 index 0000000..789a5b0 --- /dev/null +++ b/include/boost/system/is_error_code_enum.hpp @@ -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 struct is_error_code_enum +{ + static const bool value = false; +}; + +} // namespace system + +} // namespace boost + +#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CODE_ENUM_HPP_INCLUDED diff --git a/include/boost/system/is_error_condition_enum.hpp b/include/boost/system/is_error_condition_enum.hpp new file mode 100644 index 0000000..15fb6d4 --- /dev/null +++ b/include/boost/system/is_error_condition_enum.hpp @@ -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 struct is_error_condition_enum +{ + static const bool value = false; +}; + +} // namespace system + +} // namespace boost + +#endif // #ifndef BOOST_SYSTEM_IS_ERROR_CONDITION_ENUM_HPP_INCLUDED diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 52de73c..c60d119 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -73,3 +73,6 @@ lib std_single_instance_lib2 : std_single_instance_2.cpp : shared: 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 : : : static : std_single_instance_lib_static ; run std_single_instance_test.cpp std_single_instance_lib1 std_single_instance_lib2 : : : shared STD_SINGLE_INSTANCE_SHARED : std_single_instance_lib_shared ; + +run is_error_code_enum_test.cpp ; +run is_error_condition_enum_test.cpp ; diff --git a/test/is_error_code_enum_test.cpp b/test/is_error_code_enum_test.cpp new file mode 100644 index 0000000..c4840af --- /dev/null +++ b/test/is_error_code_enum_test.cpp @@ -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 +#include + +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(); +} diff --git a/test/is_error_condition_enum_test.cpp b/test/is_error_condition_enum_test.cpp new file mode 100644 index 0000000..c53714a --- /dev/null +++ b/test/is_error_condition_enum_test.cpp @@ -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 +#include + +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(); +}