diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2012-02-21 21:46:43 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2012-02-21 21:46:43 +0000 |
| commit | f2f2d8b98d7a7ae89f4c646be6dea7730b6409e0 (patch) | |
| tree | 1dc829eb7a2207b8f516cdbab3ab57ec5f3ba4df /libcxx/include | |
| parent | bd61856d91004d3534d7589da7d7062ebd74d3f5 (diff) | |
| download | bcm5719-llvm-f2f2d8b98d7a7ae89f4c646be6dea7730b6409e0.tar.gz bcm5719-llvm-f2f2d8b98d7a7ae89f4c646be6dea7730b6409e0.zip | |
Modernize conversion to bool to the explicit bool conversion operator (library wide). This fixes http://llvm.org/bugs/show_bug.cgi?id=12058.
llvm-svn: 151088
Diffstat (limited to 'libcxx/include')
| -rw-r--r-- | libcxx/include/__config | 6 | ||||
| -rw-r--r-- | libcxx/include/__mutex_base | 2 | ||||
| -rw-r--r-- | libcxx/include/exception | 2 | ||||
| -rw-r--r-- | libcxx/include/functional | 2 | ||||
| -rw-r--r-- | libcxx/include/ios | 3 | ||||
| -rw-r--r-- | libcxx/include/istream | 2 | ||||
| -rw-r--r-- | libcxx/include/memory | 13 | ||||
| -rw-r--r-- | libcxx/include/ostream | 2 | ||||
| -rw-r--r-- | libcxx/include/system_error | 4 |
9 files changed, 22 insertions, 14 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config index 5e0db7c95a1..6d551c94333 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -376,6 +376,12 @@ template <unsigned> struct __static_assert_check {}; #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) \ diff --git a/libcxx/include/__mutex_base b/libcxx/include/__mutex_base index 55687659a03..5410272b4c9 100644 --- a/libcxx/include/__mutex_base +++ b/libcxx/include/__mutex_base @@ -207,7 +207,7 @@ public: _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_;} diff --git a/libcxx/include/exception b/libcxx/include/exception index dcef3e55979..f7c3b70b00e 100644 --- a/libcxx/include/exception +++ b/libcxx/include/exception @@ -132,7 +132,7 @@ public: ~exception_ptr() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - // explicit + _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __ptr_ != nullptr;} friend _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/functional b/libcxx/include/functional index 8f912fb0f19..f941df261fe 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -1163,7 +1163,7 @@ public: // 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> diff --git a/libcxx/include/ios b/libcxx/include/ios index 3aa066bfe63..51d50870b60 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -572,7 +572,8 @@ public: 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();} diff --git a/libcxx/include/istream b/libcxx/include/istream index c22053296ce..7312425eb07 100644 --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -256,7 +256,7 @@ public: // ~sentry() = default; _LIBCPP_INLINE_VISIBILITY - // explicit + _LIBCPP_EXPLICIT operator bool() const {return __ok_;} }; diff --git a/libcxx/include/memory b/libcxx/include/memory index e3dd467b30f..aa24f960aec 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2688,9 +2688,9 @@ public: {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 @@ public: {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 @@ public: _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 diff --git a/libcxx/include/ostream b/libcxx/include/ostream index c4e6b38b515..e6dd4b578be 100644 --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -220,7 +220,7 @@ public: ~sentry(); _LIBCPP_ALWAYS_INLINE - // explicit + _LIBCPP_EXPLICIT operator bool() const {return __ok_;} }; diff --git a/libcxx/include/system_error b/libcxx/include/system_error index 971be337472..805c6464883 100644 --- a/libcxx/include/system_error +++ b/libcxx/include/system_error @@ -451,7 +451,7 @@ public: string message() const; _LIBCPP_ALWAYS_INLINE - //explicit + _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __val_ != 0;} }; @@ -528,7 +528,7 @@ public: string message() const; _LIBCPP_ALWAYS_INLINE - //explicit + _LIBCPP_EXPLICIT operator bool() const _NOEXCEPT {return __val_ != 0;} }; |

