diff options
Diffstat (limited to 'libcxx/include')
| -rw-r--r-- | libcxx/include/__config | 3 | ||||
| -rw-r--r-- | libcxx/include/ios | 21 |
2 files changed, 21 insertions, 3 deletions
diff --git a/libcxx/include/__config b/libcxx/include/__config index 467ab00a1a5..321e7177822 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -727,7 +727,8 @@ template <unsigned> struct __static_assert_check {}; #define _NOALIAS #endif -#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) +#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \ + (!defined(_LIBCPP_CXX03_LANG) && defined(__GNUC__)) // All supported GCC versions # define _LIBCPP_EXPLICIT explicit #else # define _LIBCPP_EXPLICIT diff --git a/libcxx/include/ios b/libcxx/include/ios index cbea478a74a..fb8f88dddab 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -572,6 +572,13 @@ ios_base::exceptions(iostate __iostate) 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 @@ public: 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);} |

