[PATCH] D40415: [libcxx

Mikhail Maltsev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 24 03:30:10 PST 2017


miyuki created this revision.
Herald added a reviewer: EricWF.

https://reviews.llvm.org/D40415

Files:
  include/iterator
  test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp


Index: test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
===================================================================
--- test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
+++ test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
@@ -49,4 +49,7 @@
 
     assert(i4 == i4);
     assert(i4 == i5);
+
+    assert(std::operator==(i1, i2));
+    assert(std::operator!=(i1, i3));
 }
Index: include/iterator
===================================================================
--- include/iterator
+++ include/iterator
@@ -904,15 +904,37 @@
     _LIBCPP_INLINE_VISIBILITY istream_iterator  operator++(int)
         {istream_iterator __t(*this); ++(*this); return __t;}
 
+    template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
     friend _LIBCPP_INLINE_VISIBILITY
-    bool operator==(const istream_iterator& __x, const istream_iterator& __y)
-        {return __x.__in_stream_ == __y.__in_stream_;}
+    bool
+    operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+               const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
 
+    template <class _Up, class _CharU, class _TraitsU, class _DistanceU>
     friend _LIBCPP_INLINE_VISIBILITY
-    bool operator!=(const istream_iterator& __x, const istream_iterator& __y)
-        {return !(__x == __y);}
+    bool
+    operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+               const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
 };
 
+template <class _Tp, class _CharT, class _Traits, class _Distance>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+           const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+    return __x.__in_stream_ == __y.__in_stream_;
+}
+
+template <class _Tp, class _CharT, class _Traits, class _Distance>
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+           const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+    return !(__x == __y);
+}
+
 template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
 class _LIBCPP_TEMPLATE_VIS ostream_iterator
     : public iterator<output_iterator_tag, void, void, void, void>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40415.124155.patch
Type: text/x-patch
Size: 2403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171124/6fa6290c/attachment.bin>


More information about the cfe-commits mailing list