1 #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
2 #define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED
4 // Copyright Beman Dawes 2006, 2007
5 // Copyright Christoper Kohlhoff 2007
6 // Copyright Peter Dimov 2017, 2018
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)
11 // See library home page at http://www.boost.org/libs/system
13 #include <boost/system/detail/error_category.hpp>
14 #include <boost/system/detail/config.hpp>
15 #include <boost/config.hpp>
26 // system_error_category
28 #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
33 class BOOST_SYMBOL_VISIBLE system_error_category: public error_category
37 BOOST_SYSTEM_CONSTEXPR system_error_category() BOOST_NOEXCEPT:
38 error_category( detail::system_category_id )
42 const char * name() const BOOST_NOEXCEPT BOOST_OVERRIDE
47 error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT BOOST_OVERRIDE;
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;
53 #if ( defined( BOOST_GCC ) && BOOST_GCC >= 40600 ) || defined( BOOST_CLANG )
54 #pragma GCC diagnostic pop
61 #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
66 template<class T> struct BOOST_SYMBOL_VISIBLE system_cat_holder
68 static constexpr system_error_category instance{};
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;
78 constexpr error_category const & system_category() BOOST_NOEXCEPT
80 return detail::system_cat_holder<void>::instance;
83 #else // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
85 #if !defined(__SUNPRO_CC) // trailing __global is not supported
86 inline error_category const & system_category() BOOST_NOEXCEPT BOOST_SYMBOL_VISIBLE;
89 inline error_category const & system_category() BOOST_NOEXCEPT
91 static const detail::system_error_category instance;
95 #endif // #if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
97 // deprecated synonyms
99 #ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
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();
106 } // namespace system
110 #endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_HPP_INCLUDED