1#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED
2#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED
3
4// Support for interoperability between Boost.System and <system_error>
5//
6// Copyright 2018, 2021 Peter Dimov
7//
8// Distributed under the Boost Software License, Version 1.0. (See accompanying
9// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10//
11// See library home page at http://www.boost.org/libs/system
12
13#include <boost/system/detail/std_category.hpp>
14#include <boost/system/detail/error_condition.hpp>
15#include <boost/system/detail/error_code.hpp>
16#include <boost/system/detail/generic_category.hpp>
17
18//
19
20namespace boost
21{
22
23namespace system
24{
25
26namespace detail
27{
28
29inline bool std_category::equivalent( int code, const std::error_condition & condition ) const noexcept
30{
31 if( condition.category() == *this )
32 {
33 boost::system::error_condition bn( condition.value(), *pc_ );
34 return pc_->equivalent( code, condition: bn );
35 }
36 else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() )
37 {
38 boost::system::error_condition bn( condition.value(), boost::system::generic_category() );
39 return pc_->equivalent( code, condition: bn );
40 }
41
42#ifndef BOOST_NO_RTTI
43
44 else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) )
45 {
46 boost::system::error_condition bn( condition.value(), *pc2->pc_ );
47 return pc_->equivalent( code, condition: bn );
48 }
49
50#endif
51
52 else
53 {
54 return default_error_condition( ev: code ) == condition;
55 }
56}
57
58inline bool std_category::equivalent( const std::error_code & code, int condition ) const noexcept
59{
60 if( code.category() == *this )
61 {
62 boost::system::error_code bc( code.value(), *pc_ );
63 return pc_->equivalent( code: bc, condition );
64 }
65 else if( code.category() == std::generic_category() || code.category() == boost::system::generic_category() )
66 {
67 boost::system::error_code bc( code.value(), boost::system::generic_category() );
68 return pc_->equivalent( code: bc, condition );
69 }
70
71#ifndef BOOST_NO_RTTI
72
73 else if( std_category const* pc2 = dynamic_cast< std_category const* >( &code.category() ) )
74 {
75 boost::system::error_code bc( code.value(), *pc2->pc_ );
76 return pc_->equivalent( code: bc, condition );
77 }
78
79#endif
80
81 else if( *pc_ == boost::system::generic_category() )
82 {
83 return std::generic_category().equivalent( code: code, i: condition );
84 }
85 else
86 {
87 return false;
88 }
89}
90
91} // namespace detail
92
93} // namespace system
94
95} // namespace boost
96
97#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_IMPL_HPP_INCLUDED
98

source code of boost/libs/system/include/boost/system/detail/std_category_impl.hpp