1#ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
2#define BOOST_SYSTEM_DETAIL_STD_CATEGORY_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/error_category.hpp>
14#include <boost/config.hpp>
15#include <system_error>
16
17//
18
19namespace boost
20{
21
22namespace system
23{
24
25namespace detail
26{
27
28template<unsigned Id> struct id_wrapper {};
29
30class BOOST_SYMBOL_VISIBLE std_category: public std::error_category
31{
32private:
33
34 boost::system::error_category const * pc_;
35
36public:
37
38 boost::system::error_category const & original_category() const noexcept
39 {
40 return *pc_;
41 }
42
43public:
44
45 template<unsigned Id>
46 explicit std_category( boost::system::error_category const * pc, id_wrapper<Id> ): pc_( pc )
47 {
48#if defined(_MSC_VER) && defined(_CPPLIB_VER) && _MSC_VER >= 1900 && _MSC_VER < 2000
49
50 // We used to assign to the protected _Addr member of std::error_category
51 // here when Id != 0, but this should never happen now because this code
52 // path is no longer used
53
54 static_assert( Id == 0, "This constructor should only be called with Id == 0 under MS STL 14.0+" );
55
56#endif
57 }
58
59 const char * name() const noexcept BOOST_OVERRIDE
60 {
61 return pc_->name();
62 }
63
64 std::string message( int ev ) const BOOST_OVERRIDE
65 {
66 return pc_->message( ev );
67 }
68
69 std::error_condition default_error_condition( int ev ) const noexcept BOOST_OVERRIDE
70 {
71 return pc_->default_error_condition( ev );
72 }
73
74 inline bool equivalent( int code, const std::error_condition & condition ) const noexcept BOOST_OVERRIDE;
75 inline bool equivalent( const std::error_code & code, int condition ) const noexcept BOOST_OVERRIDE;
76};
77
78} // namespace detail
79
80} // namespace system
81
82} // namespace boost
83
84#endif // #ifndef BOOST_SYSTEM_DETAIL_STD_CATEGORY_HPP_INCLUDED
85

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