Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | } |