Do not put categories in an unnamed namespace, as this is an ODR violation in header-only mode

This commit is contained in:
Peter Dimov
2018-01-14 05:56:15 +02:00
parent f8ef12bcc4
commit d28c6ff128

View File

@ -38,7 +38,7 @@ namespace boost
namespace system namespace system
{ {
namespace namespace detail
{ {
// standard error categories -------------------------------------------------------// // standard error categories -------------------------------------------------------//
@ -60,14 +60,20 @@ namespace
error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT;
}; };
#ifdef BOOST_ERROR_CODE_HEADER_ONLY
# define BOOST_SYSTEM_INLINE inline
#else
# define BOOST_SYSTEM_INLINE
#endif
// generic_error_category implementation ---------------------------------// // generic_error_category implementation ---------------------------------//
const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT BOOST_SYSTEM_INLINE const char * generic_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "generic"; return "generic";
} }
std::string generic_error_category::message( int ev ) const BOOST_SYSTEM_INLINE std::string generic_error_category::message( int ev ) const
{ {
using namespace boost::system::errc; using namespace boost::system::errc;
#if defined(__PGI) #if defined(__PGI)
@ -160,12 +166,12 @@ namespace
} }
// system_error_category implementation --------------------------------------------// // system_error_category implementation --------------------------------------------//
const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT BOOST_SYSTEM_INLINE const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT
{ {
return "system"; return "system";
} }
error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_INLINE error_condition system_error_category::default_error_condition( int ev ) const
BOOST_SYSTEM_NOEXCEPT BOOST_SYSTEM_NOEXCEPT
{ {
using namespace boost::system::errc; using namespace boost::system::errc;
@ -370,13 +376,13 @@ namespace
# if !defined( BOOST_WINDOWS_API ) # if !defined( BOOST_WINDOWS_API )
std::string system_error_category::message( int ev ) const BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
{ {
return generic_category().message( ev ); return generic_category().message( ev );
} }
# else # else
std::string system_error_category::message( int ev ) const BOOST_SYSTEM_INLINE std::string system_error_category::message( int ev ) const
{ {
#if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS) #if defined(UNDER_CE) || BOOST_PLAT_WINDOWS_RUNTIME || defined(BOOST_NO_ANSI_APIS)
std::wstring buf(128, wchar_t()); std::wstring buf(128, wchar_t());
@ -455,7 +461,9 @@ namespace
} }
# endif # endif
} // unnamed namespace #undef BOOST_SYSTEM_INLINE
} // namespace detail
# ifdef BOOST_SYSTEM_ENABLE_DEPRECATED # ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
@ -474,13 +482,13 @@ namespace
BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT BOOST_SYSTEM_LINKAGE const error_category & system_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const system_error_category system_category_const; static const detail::system_error_category system_category_const;
return system_category_const; return system_category_const;
} }
BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT BOOST_SYSTEM_LINKAGE const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT
{ {
static const generic_error_category generic_category_const; static const detail::generic_error_category generic_category_const;
return generic_category_const; return generic_category_const;
} }