Commit 77a6c969 by Jonathan Wakely Committed by Jonathan Wakely

Replace safe bool idiom with explicit operator bool

	* include/ext/pointer.h [__cplusplus >= 201103L]
	(_Pointer_adapter::operator bool): Add explicit conversion operator
	to replace safe bool idiom.

From-SVN: r263162
parent ddf98a96
2018-07-31 Jonathan Wakely <jwakely@redhat.com>
* include/ext/pointer.h [__cplusplus >= 201103L]
(_Pointer_adapter::operator bool): Add explicit conversion operator
to replace safe bool idiom.
2018-07-30 Jonathan Wakely <jwakely@redhat.com> 2018-07-30 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/86734 PR libstdc++/86734
......
...@@ -356,6 +356,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -356,6 +356,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _Storage_policy::get()[__index]; } { return _Storage_policy::get()[__index]; }
// To allow implicit conversion to "bool", for "if (ptr)..." // To allow implicit conversion to "bool", for "if (ptr)..."
#if __cplusplus >= 201103L
explicit operator bool() const { return _Storage_policy::get() != 0; }
#else
private: private:
typedef element_type*(_Pointer_adapter::*__unspecified_bool_type)() const; typedef element_type*(_Pointer_adapter::*__unspecified_bool_type)() const;
...@@ -370,6 +373,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -370,6 +373,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
inline bool inline bool
operator!() const operator!() const
{ return (_Storage_policy::get() == 0); } { return (_Storage_policy::get() == 0); }
#endif
// Pointer differences // Pointer differences
inline friend std::ptrdiff_t inline friend std::ptrdiff_t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment