]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/system/detail/system_category.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / system / detail / system_category.hpp
1 #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
2 #define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
3
4 // Copyright Beman Dawes 2006, 2007
5 // Copyright Christoper Kohlhoff 2007
6 // Copyright Peter Dimov 2017, 2018
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/system/detail/config.hpp>
15 #include <boost/config.hpp>
16
17 namespace boost
18 {
19
20 namespace system
21 {
22
23 namespace detail
24 {
25
26 // system_error_category
27
28 #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
31 #endif
32
33 class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
34 {
35 public:
36
37 BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
38 error_category( detail::system_category_id )
39 {
40 }
41
42 const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
43 {
44 return "system";
45 }
46
47 error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
48
49 std::string message( int ev ) const BOOST_OVERRIDE;
50 char const * message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
51 };
52
53 #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
54 #pragma GCC diagnostic pop
55 #endif
56
57 } // namespace detail
58
59 // system_category()
60
61 #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
62
63 namespace detail
64 {
65
66 template<class T> struct BOOST_SYMBOL_VISIBLE system_cat_holder
67 {
68 static constexpr system_error_category instance{};
69 };
70
71 // Before C++17 it was mandatory to redeclare all static constexpr
72 #if defined(BOOST_NO_CXX17_INLINE_VARIABLES)
73 template<class T> constexpr system_error_category system_cat_holder<T>::instance;
74 #endif
75
76 } // namespace detail
77
78 constexpr error_category const & system_category() BOOST_NOEXCEPT
79 {
80 return detail::system_cat_holder<void>::instance;
81 }
82
83 #else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
84
85 #if !defined(__SUNPRO_CC) // trailing __global is not supported
86 inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
87 #endif
88
89 inline error_category const & system_category() BOOST_NOEXCEPT
90 {
91 static const detail::system_error_category instance;
92 return instance;
93 }
94
95 #endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
96
97 // deprecated synonyms
98
99 #ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
100
101 BOOST_SYSTEM_DEPRECATED("please use system_category()") inline const error_category & get_system_category() { return system_category(); }
102 BOOST_SYSTEM_DEPRECATED("please use system_category()") static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category();
103
104 #endif
105
106 } // namespace system
107
108 } // namespace boost
109
110 #endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED