Home | History | Annotate | Download | only in istream.iterator.ops
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <iterator>
     11 
     12 // class istream_iterator
     13 
     14 // const T* operator->() const;
     15 
     16 #include <iterator>
     17 #include <sstream>
     18 #include <cassert>
     19 
     20 struct A
     21 {
     22     double d_;
     23     int i_;
     24 };
     25 
     26 std::istream& operator>>(std::istream& is, A& a)
     27 {
     28     return is >> a.d_ >> a.i_;
     29 }
     30 
     31 int main()
     32 {
     33     std::istringstream inf("1.5  23 ");
     34     std::istream_iterator<A> i(inf);
     35     assert(i->d_ == 1.5);
     36     assert(i->i_ == 23);
     37 }
     38