Recommit r290750: Fix PR19460 - std::ios is convertible to int.

There were two problems with the initial fix.

1. The added tests flushed out that we misconfigured _LIBCPP_EXPLICIT with GCC.

2. Because the boolean type was a member function template it caused weird link
   errors. I'm assuming due to the vague linkage rules. This time the bool type
   is a non-template member function pointer. That seems to have fixed the
   failing tests. Plus it will end up generating less symbols overall, since
   the bool type is no longer per instantiation.

original commit message below
-----------------------------

std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

llvm-svn: 290754
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 1b06dfe7b7e8514f823385352e7408f041e45fcf
diff --git a/include/ios b/include/ios
index cbea478..fb8f88d 100644
--- a/include/ios
+++ b/include/ios
@@ -572,6 +572,13 @@
     clear(__rdstate_);
 }
 
+#if defined(_LIBCPP_CXX03_LANG)
+struct _LIBCPP_TYPE_VIS_ONLY __cxx03_bool {
+  typedef void (__cxx03_bool::*__bool_type)();
+  void __true_value() {}
+};
+#endif
+
 template <class _CharT, class _Traits>
 class _LIBCPP_TYPE_VIS_ONLY basic_ios
     : public ios_base
@@ -585,9 +592,19 @@
     typedef typename traits_type::pos_type pos_type;
     typedef typename traits_type::off_type off_type;
 
+  // __true_value will generate undefined references when linking unless
+  // we give it internal linkage.
+
+#if defined(_LIBCPP_CXX03_LANG)
     _LIBCPP_ALWAYS_INLINE
-        _LIBCPP_EXPLICIT
-        operator bool() const {return !fail();}
+    operator __cxx03_bool::__bool_type() const {
+        return !fail() ? &__cxx03_bool::__true_value : nullptr;
+    }
+#else
+    _LIBCPP_ALWAYS_INLINE
+    _LIBCPP_EXPLICIT operator bool() const {return !fail();}
+#endif
+
     _LIBCPP_ALWAYS_INLINE bool operator!() const    {return  fail();}
     _LIBCPP_ALWAYS_INLINE iostate rdstate() const   {return ios_base::rdstate();}
     _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}