mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
Use explicit operator bool when available
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// Copyright Beman Dawes 2006, 2007
|
// Copyright Beman Dawes 2006, 2007
|
||||||
// Copyright Christoper Kohlhoff 2007
|
// Copyright Christoper Kohlhoff 2007
|
||||||
|
// Copyright Peter Dimov 2017, 2018
|
||||||
|
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -387,6 +388,15 @@ namespace boost
|
|||||||
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
|
const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; }
|
||||||
std::string message() const { return m_cat->message(value()); }
|
std::string message() const { return m_cat->message(value()); }
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||||
|
|
||||||
|
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return m_val != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)();
|
typedef void (*unspecified_bool_type)();
|
||||||
static void unspecified_bool_true() {}
|
static void unspecified_bool_true() {}
|
||||||
|
|
||||||
@ -400,6 +410,8 @@ namespace boost
|
|||||||
return m_val == 0;
|
return m_val == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// relationals:
|
// relationals:
|
||||||
// the more symmetrical non-member syntax allows enum
|
// the more symmetrical non-member syntax allows enum
|
||||||
// conversions work for both rhs and lhs.
|
// conversions work for both rhs and lhs.
|
||||||
@ -486,6 +498,15 @@ namespace boost
|
|||||||
{ return m_cat->default_error_condition(value()); }
|
{ return m_cat->default_error_condition(value()); }
|
||||||
std::string message() const { return m_cat->message(value()); }
|
std::string message() const { return m_cat->message(value()); }
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
|
||||||
|
|
||||||
|
explicit operator bool() const BOOST_SYSTEM_NOEXCEPT // true if error
|
||||||
|
{
|
||||||
|
return m_val != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
typedef void (*unspecified_bool_type)();
|
typedef void (*unspecified_bool_type)();
|
||||||
static void unspecified_bool_true() {}
|
static void unspecified_bool_true() {}
|
||||||
|
|
||||||
@ -499,6 +520,8 @@ namespace boost
|
|||||||
return m_val == 0;
|
return m_val == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// relationals:
|
// relationals:
|
||||||
inline friend bool operator==( const error_code & lhs,
|
inline friend bool operator==( const error_code & lhs,
|
||||||
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
|
const error_code & rhs ) BOOST_SYSTEM_NOEXCEPT
|
||||||
|
@ -30,7 +30,7 @@ int main()
|
|||||||
|
|
||||||
BOOST_TEST( bt.equivalent( ev, bn ) );
|
BOOST_TEST( bt.equivalent( ev, bn ) );
|
||||||
|
|
||||||
BOOST_TEST_EQ( bc, bn );
|
BOOST_TEST( bc == bn );
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user