System: move throws function to namespace boost to allow peaceful coexistence with throws object.
[SVN r50727]
This commit is contained in:
parent
5bc362e4f3
commit
f1cdde273a
@ -384,18 +384,30 @@ namespace boost
|
||||
};
|
||||
|
||||
// predefined error_code object used as "throw on error" tag
|
||||
# ifndef BOOST_SYSTEM_THROWS_FUNCTION
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
BOOST_SYSTEM_DECL extern error_code throws;
|
||||
# else
|
||||
namespace detail { inline error_code * throws() { return 0; } }
|
||||
// prevent misuse by poisoning the reference in a way that doesn't
|
||||
// produce warnings or errors from popular compilers, and is also
|
||||
// very efficient (as determined by inspectiing generated code)
|
||||
|
||||
inline error_code & throws()
|
||||
{ return *detail::throws(); }
|
||||
# endif
|
||||
|
||||
// Moving from a "throws" object to a "throws" function without breaking
|
||||
// existing code is a bit of a problem. The workaround is to place the
|
||||
// "throws" function in namespace boost rather than namespace boost::system.
|
||||
|
||||
} // namespace system
|
||||
|
||||
namespace detail { inline system::error_code * throws() { return 0; } }
|
||||
// Misuse of the error_code object is turned into a noisy failure by
|
||||
// poisoning the reference. This particular implementation doesn't
|
||||
// produce warnings or errors from popular compilers, is very efficient
|
||||
// (as determined by inspecting generated code), and does not suffer
|
||||
// from order of initialization problems. In practice, it also seems
|
||||
// cause user function error handling implementation errors to be detected
|
||||
// very early in the development cycle.
|
||||
|
||||
inline system::error_code & throws()
|
||||
{ return *detail::throws(); }
|
||||
|
||||
namespace system
|
||||
{
|
||||
// non-member functions ------------------------------------------------//
|
||||
|
||||
inline bool operator!=( const error_code & lhs,
|
||||
|
@ -411,7 +411,7 @@ namespace boost
|
||||
namespace system
|
||||
{
|
||||
|
||||
# ifndef BOOST_SYSTEM_THROWS_FUNCTION
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code;
|
||||
// note that it doesn't matter if this
|
||||
// isn't initialized before use since
|
||||
|
Loading…
Reference in New Issue
Block a user