Home | History | Annotate | Download | only in istream.iterator.cons
      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 // istream_iterator(const istream_iterator& x);
     15 //  C++17 says:  If is_trivially_copy_constructible_v<T> is true, then
     16 //     this constructor is a trivial copy constructor.
     17 
     18 #include <iterator>
     19 #include <sstream>
     20 #include <cassert>
     21 
     22 #include "test_macros.h"
     23 
     24 int main()
     25 {
     26     {
     27         std::istream_iterator<int> io;
     28         std::istream_iterator<int> i = io;
     29         assert(i == std::istream_iterator<int>());
     30     }
     31     {
     32         std::istringstream inf(" 1 23");
     33         std::istream_iterator<int> io(inf);
     34         std::istream_iterator<int> i = io;
     35         assert(i != std::istream_iterator<int>());
     36         int j = 0;
     37         j = *i;
     38         assert(j == 1);
     39     }
     40 }
     41