[cfe-commits] [libcxx] r151088 - in /libcxx/trunk/include: __config __mutex_base exception functional ios istream memory ostream system_error
Howard Hinnant
hhinnant at apple.com
Tue Feb 21 13:46:43 PST 2012
Author: hhinnant
Date: Tue Feb 21 15:46:43 2012
New Revision: 151088
URL: http://llvm.org/viewvc/llvm-project?rev=151088&view=rev
Log:
Modernize conversion to bool to the explicit bool conversion operator (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058.
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/exception
libcxx/trunk/include/functional
libcxx/trunk/include/ios
libcxx/trunk/include/istream
libcxx/trunk/include/memory
libcxx/trunk/include/ostream
libcxx/trunk/include/system_error
Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Tue Feb 21 15:46:43 2012
@@ -376,6 +376,12 @@
#define __has_feature(__x) 0
#endif
+#if __has_feature(cxx_explicit_conversions)
+# define _LIBCPP_EXPLICIT explicit
+#else
+# define _LIBCPP_EXPLICIT
+#endif
+
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS
#define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_VISIBLE x { enum _
#define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \
Modified: libcxx/trunk/include/__mutex_base
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Tue Feb 21 15:46:43 2012
@@ -207,7 +207,7 @@
_LIBCPP_INLINE_VISIBILITY
bool owns_lock() const {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
-// explicit
+ _LIBCPP_EXPLICIT
operator bool () const {return __owns_;}
_LIBCPP_INLINE_VISIBILITY
mutex_type* mutex() const {return __m_;}
Modified: libcxx/trunk/include/exception
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue Feb 21 15:46:43 2012
@@ -132,7 +132,7 @@
~exception_ptr() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- // explicit
+ _LIBCPP_EXPLICIT
operator bool() const _NOEXCEPT {return __ptr_ != nullptr;}
friend _LIBCPP_INLINE_VISIBILITY
Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Tue Feb 21 15:46:43 2012
@@ -1163,7 +1163,7 @@
// function capacity:
_LIBCPP_INLINE_VISIBILITY
- /*explicit*/ operator bool() const _NOEXCEPT {return __f_;}
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __f_;}
// deleted overloads close possible hole in the type system
template<class _R2, class... _ArgTypes2>
Modified: libcxx/trunk/include/ios
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ios?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/ios (original)
+++ libcxx/trunk/include/ios Tue Feb 21 15:46:43 2012
@@ -572,7 +572,8 @@
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
- _LIBCPP_ALWAYS_INLINE // explicit
+ _LIBCPP_ALWAYS_INLINE
+ _LIBCPP_EXPLICIT
operator bool() const {return !fail();}
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
Modified: libcxx/trunk/include/istream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Tue Feb 21 15:46:43 2012
@@ -256,7 +256,7 @@
// ~sentry() = default;
_LIBCPP_INLINE_VISIBILITY
- // explicit
+ _LIBCPP_EXPLICIT
operator bool() const {return __ok_;}
};
Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Feb 21 15:46:43 2012
@@ -2688,9 +2688,9 @@
{return __ptr_.second();}
_LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
{return __ptr_.second();}
- _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const
- _NOEXCEPT
- {return __ptr_.first() ? &__nat::__for_bool_ : 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+ {return __ptr_.first() != nullptr;}
_LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
{
@@ -2881,8 +2881,9 @@
{return __ptr_.second();}
_LIBCPP_INLINE_VISIBILITY _Dp_const_reference get_deleter() const _NOEXCEPT
{return __ptr_.second();}
- _LIBCPP_INLINE_VISIBILITY operator int __nat::*() const _NOEXCEPT
- {return __ptr_.first() ? &__nat::__for_bool_ : 0;}
+ _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT
+ {return __ptr_.first() != nullptr;}
_LIBCPP_INLINE_VISIBILITY pointer release() _NOEXCEPT
{
@@ -3937,7 +3938,7 @@
_LIBCPP_INLINE_VISIBILITY
bool unique() const _NOEXCEPT {return use_count() == 1;}
_LIBCPP_INLINE_VISIBILITY
- /*explicit*/ operator bool() const _NOEXCEPT {return get() != 0;}
+ _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return get() != 0;}
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
bool owner_before(shared_ptr<_Up> const& __p) const
Modified: libcxx/trunk/include/ostream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/ostream?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/ostream (original)
+++ libcxx/trunk/include/ostream Tue Feb 21 15:46:43 2012
@@ -220,7 +220,7 @@
~sentry();
_LIBCPP_ALWAYS_INLINE
- // explicit
+ _LIBCPP_EXPLICIT
operator bool() const {return __ok_;}
};
Modified: libcxx/trunk/include/system_error
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/system_error?rev=151088&r1=151087&r2=151088&view=diff
==============================================================================
--- libcxx/trunk/include/system_error (original)
+++ libcxx/trunk/include/system_error Tue Feb 21 15:46:43 2012
@@ -451,7 +451,7 @@
string message() const;
_LIBCPP_ALWAYS_INLINE
- //explicit
+ _LIBCPP_EXPLICIT
operator bool() const _NOEXCEPT {return __val_ != 0;}
};
@@ -528,7 +528,7 @@
string message() const;
_LIBCPP_ALWAYS_INLINE
- //explicit
+ _LIBCPP_EXPLICIT
operator bool() const _NOEXCEPT {return __val_ != 0;}
};
More information about the cfe-commits
mailing list