mirror of
https://github.com/boostorg/system.git
synced 2025-07-29 20:17:13 +02:00
Enable constexpr in header-only mode as well
This commit is contained in:
@ -452,20 +452,11 @@ namespace detail
|
||||
|
||||
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
#define BOOST_SYSTEM_CONST_INIT
|
||||
|
||||
#if defined(__has_cpp_attribute)
|
||||
#if __has_cpp_attribute(clang::require_constant_initialization)
|
||||
# undef BOOST_SYSTEM_CONST_INIT
|
||||
# define BOOST_SYSTEM_CONST_INIT [[clang::require_constant_initialization]]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
BOOST_SYSTEM_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
|
||||
BOOST_SYSTEM_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
|
||||
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL system_error_category system_category_instance;
|
||||
BOOST_SYSTEM_REQUIRE_CONST_INIT BOOST_SYSTEM_DECL generic_error_category generic_category_instance;
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & system_category_ncx() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
@ -479,8 +470,6 @@ BOOST_SYSTEM_DECL const error_category & generic_category_ncx() BOOST_SYSTEM_NOE
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#undef BOOST_SYSTEM_CONST_INIT
|
||||
|
||||
#else
|
||||
|
||||
namespace detail
|
||||
|
@ -38,7 +38,7 @@
|
||||
#define BOOST_SYSTEM_NOEXCEPT BOOST_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX14_CONSTEXPR) && !defined(BOOST_ERROR_CODE_HEADER_ONLY)
|
||||
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
# define BOOST_SYSTEM_HAS_CONSTEXPR
|
||||
#endif
|
||||
|
||||
@ -373,20 +373,59 @@ public:
|
||||
|
||||
} // namespace detail
|
||||
|
||||
#define BOOST_SYSTEM_REQUIRE_CONST_INIT
|
||||
|
||||
#if defined(__has_cpp_attribute)
|
||||
#if __has_cpp_attribute(clang::require_constant_initialization)
|
||||
# undef BOOST_SYSTEM_REQUIRE_CONST_INIT
|
||||
# define BOOST_SYSTEM_REQUIRE_CONST_INIT [[clang::require_constant_initialization]]
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_ERROR_CODE_HEADER_ONLY)
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
# if defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct cat_holder
|
||||
{
|
||||
static system_error_category system_category_instance;
|
||||
static generic_error_category generic_category_instance;
|
||||
};
|
||||
|
||||
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT system_error_category cat_holder<T>::system_category_instance;
|
||||
template<class T> BOOST_SYSTEM_REQUIRE_CONST_INIT generic_error_category cat_holder<T>::generic_category_instance;
|
||||
|
||||
} // namespace detail
|
||||
|
||||
constexpr const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::cat_holder<void>::system_category_instance;
|
||||
}
|
||||
|
||||
constexpr const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
return detail::cat_holder<void>::generic_category_instance;
|
||||
}
|
||||
|
||||
# else
|
||||
|
||||
inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::system_error_category system_category_instance;
|
||||
return system_category_instance;
|
||||
}
|
||||
|
||||
BOOST_SYSTEM_CONSTEXPR inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
inline const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
|
||||
{
|
||||
static const detail::generic_error_category generic_category_instance;
|
||||
return generic_category_instance;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
#elif defined(BOOST_SYSTEM_HAS_CONSTEXPR)
|
||||
|
||||
namespace detail
|
||||
|
Reference in New Issue
Block a user