[libc++] Enable `explicit` conversion operators, even in C++03 mode.
C++03 didn't support `explicit` conversion operators;
but Clang's C++03 mode does, as an extension, so we can use it.
This lets us make the conversion explicit in `std::function` (even in '03),
and remove some silly metaprogramming in `std::basic_ios`.
Drive-by improvements to the tests for these operators, in addition
to making sure all these tests also run in `c++03` mode.
Differential Revision: https://reviews.llvm.org/D104682
NOKEYCHECK=True
GitOrigin-RevId: 317e92a3e82f88f111e04132195d9daa6b97f1ab
diff --git a/include/ios b/include/ios
index c58b983..eefb58f 100644
--- a/include/ios
+++ b/include/ios
@@ -591,13 +591,6 @@
clear(__rdstate_);
}
-#if defined(_LIBCPP_CXX03_LANG)
-struct _LIBCPP_TYPE_VIS __cxx03_bool {
- typedef void (__cxx03_bool::*__bool_type)();
- void __true_value() {}
-};
-#endif
-
template <class _CharT, class _Traits>
class _LIBCPP_TEMPLATE_VIS basic_ios
: public ios_base
@@ -614,18 +607,8 @@
static_assert((is_same<_CharT, typename traits_type::char_type>::value),
"traits_type::char_type must be the same type as CharT");
- // __true_value will generate undefined references when linking unless
- // we give it internal linkage.
-
-#if defined(_LIBCPP_CXX03_LANG)
_LIBCPP_INLINE_VISIBILITY
- operator __cxx03_bool::__bool_type() const {
- return !fail() ? &__cxx03_bool::__true_value : nullptr;
- }
-#else
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_EXPLICIT operator bool() const {return !fail();}
-#endif
+ explicit operator bool() const {return !fail();}
_LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();}
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();}