diff options
Diffstat (limited to 'libstdc++-v3/include/std/istream')
-rw-r--r-- | libstdc++-v3/include/std/istream | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream index c8a2e08e..4f0e940 100644 --- a/libstdc++-v3/include/std/istream +++ b/libstdc++-v3/include/std/istream @@ -908,6 +908,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ws(basic_istream<_CharT, _Traits>& __is); #if __cplusplus >= 201103L + + template<typename _Tp> + struct __is_convertible_to_basic_istream + { + template<typename _Ch, typename _Up> + static true_type __check(basic_istream<_Ch, _Up>*); + + static false_type __check(void*); + public: + using type = decltype(__check(declval<_Tp*>())); + constexpr static bool value = type::value; + }; + + template<typename _Istream, typename _Tp, typename = void> + struct __is_extractable : false_type {}; + + template<typename _Istream, typename _Tp> + struct __is_extractable<_Istream, _Tp, + __void_t<decltype(declval<_Istream&>() + >> declval<_Tp>())>> + : true_type {}; + // [27.7.1.6] Rvalue stream extraction // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2328. Rvalue stream extraction should use perfect forwarding @@ -921,9 +943,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * rvalue streams since they won't bind to the extractor functions * that take an lvalue reference. */ - template<typename _CharT, typename _Traits, typename _Tp> - inline basic_istream<_CharT, _Traits>& - operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp&& __x) + template<typename _Istream, typename _Tp> + inline + typename enable_if<__and_<__not_<is_lvalue_reference<_Istream>>, + __is_convertible_to_basic_istream< + typename remove_reference<_Istream>::type>, + __is_extractable<_Istream&, _Tp&&>>::value, + _Istream&>::type + operator>>(_Istream&& __is, _Tp&& __x) { __is >> std::forward<_Tp>(__x); return __is; |