|
5569 | 5569 |
|
5570 | 5570 | \pnum
|
5571 | 5571 | \indexlibrary{\idxcode{istream_iterator}}%
|
5572 |
| -The class template |
5573 |
| -\tcode{istream_iterator} |
5574 |
| -is an input iterator\iref{input.iterators} that |
5575 |
| -reads (using |
5576 |
| -\tcode{operator>>}) |
5577 |
| -successive elements from the input stream for which it was constructed. |
5578 |
| -After it is constructed, and every time |
5579 |
| -\tcode{++} |
5580 |
| -is used, the iterator reads and stores a value of |
5581 |
| -\tcode{T}. |
5582 |
| -If the iterator fails to read and store a value of \tcode{T} |
5583 |
| -(\tcode{fail()} |
5584 |
| -on the stream returns |
5585 |
| -\tcode{true}), |
5586 |
| -the iterator becomes equal to the |
5587 |
| -\term{end-of-stream} |
5588 |
| -iterator value. |
5589 |
| -The constructor with no arguments |
5590 |
| -\tcode{istream_iterator()} |
5591 |
| -always constructs |
5592 |
| -an end-of-stream input iterator object, which is the only legitimate iterator to be used |
5593 |
| -for the end condition. |
5594 |
| -The result of |
5595 |
| -\tcode{operator*} |
5596 |
| -on an end-of-stream iterator is not defined. |
5597 |
| -For any other iterator value a |
5598 |
| -\tcode{const T\&} |
5599 |
| -is returned. |
5600 |
| -The result of |
5601 |
| -\tcode{operator->} |
5602 |
| -on an end-of-stream iterator is not defined. |
5603 |
| -For any other iterator value a |
5604 |
| -\tcode{const T*} |
5605 |
| -is returned. |
5606 |
| -The behavior of a program that applies \tcode{operator++()} to an end-of-stream |
5607 |
| -iterator is undefined. |
5608 |
| -It is impossible to store things into istream iterators. |
5609 |
| -The type \tcode{T} shall satisfy the \oldconcept{DefaultConstructible}, |
5610 |
| -\oldconcept{CopyConstructible}, and \oldconcept{CopyAssignable} requirements. |
5611 |
| - |
5612 |
| -\pnum |
5613 |
| -Two end-of-stream iterators are always equal. |
5614 |
| -An end-of-stream iterator is not |
5615 |
| -equal to a non-end-of-stream iterator. |
5616 |
| -Two non-end-of-stream iterators are equal when they are constructed from the same stream. |
| 5572 | +The class template \tcode{istream_iterator} |
| 5573 | +is an input iterator\iref{input.iterators} that reads successive elements |
| 5574 | +from the input stream for which it was constructed. |
5617 | 5575 |
|
5618 | 5576 | \begin{codeblock}
|
5619 | 5577 | namespace std {
|
|
5654 | 5612 | }
|
5655 | 5613 | \end{codeblock}
|
5656 | 5614 |
|
| 5615 | +\pnum |
| 5616 | +The type \tcode{T} shall meet the \oldconcept{DefaultConstructible}, |
| 5617 | +\oldconcept{CopyConstructible}, and \oldconcept{CopyAssignable} requirements. |
| 5618 | + |
5657 | 5619 | \rSec3[istream.iterator.cons]{Constructors and destructor}
|
5658 | 5620 |
|
5659 | 5621 | \indexlibrary{\idxcode{istream_iterator}!constructor}%
|
|
5665 | 5627 | \begin{itemdescr}
|
5666 | 5628 | \pnum
|
5667 | 5629 | \effects
|
5668 |
| -Constructs the end-of-stream iterator. |
5669 |
| -If \tcode{is_trivially_default_constructible_v<T>} is \tcode{true}, |
5670 |
| -then these constructors are constexpr constructors. |
| 5630 | +Constructs the end-of-stream iterator, value-initializing \tcode{value}. |
5671 | 5631 |
|
5672 | 5632 | \pnum
|
5673 |
| -\ensures \tcode{in_stream == nullptr}. |
| 5633 | +\ensures \tcode{in_stream == nullptr} is \tcode{true}. |
| 5634 | + |
| 5635 | +\pnum |
| 5636 | +\remarks |
| 5637 | +If the initializer \tcode{T()} in the declaration \tcode{auto x = T();} |
| 5638 | +is a constant initializer\iref{expr.const}, |
| 5639 | +then these constructors are \tcode{constexpr} constructors. |
5674 | 5640 | \end{itemdescr}
|
5675 | 5641 |
|
5676 | 5642 |
|
|
5682 | 5648 | \begin{itemdescr}
|
5683 | 5649 | \pnum
|
5684 | 5650 | \effects
|
5685 |
| -Initializes \tcode{in_stream} with \tcode{addressof(s)}. |
5686 |
| -\tcode{value} may be initialized during |
5687 |
| -construction or the first time it is referenced. |
5688 |
| - |
5689 |
| -\pnum |
5690 |
| -\ensures \tcode{in_stream == addressof(s)}. |
| 5651 | +Initializes \tcode{in_stream} with \tcode{addressof(s)}, |
| 5652 | +value-initializes \tcode{value}, |
| 5653 | +and then calls \tcode{operator++()}. |
5691 | 5654 | \end{itemdescr}
|
5692 | 5655 |
|
5693 | 5656 |
|
|
5700 | 5663 | \pnum
|
5701 | 5664 | \effects
|
5702 | 5665 | Constructs a copy of \tcode{x}.
|
5703 |
| -If \tcode{is_trivially_copy_constructible_v<T>} is \tcode{true}, |
5704 |
| -then this constructor is a trivial copy constructor. |
5705 | 5666 |
|
5706 | 5667 | \pnum
|
5707 |
| -\ensures \tcode{in_stream == x.in_stream}. |
| 5668 | +\ensures \tcode{in_stream == x.in_stream} is \tcode{true}. |
| 5669 | + |
| 5670 | +\pnum |
| 5671 | +\remarks |
| 5672 | +If \tcode{is_trivially_copy_constructible_v<T>} is \tcode{true}, |
| 5673 | +then this constructor is trivial. |
5708 | 5674 | \end{itemdescr}
|
5709 | 5675 |
|
5710 | 5676 | \indexlibrary{\idxcode{istream_iterator}!destructor}%
|
|
5714 | 5680 |
|
5715 | 5681 | \begin{itemdescr}
|
5716 | 5682 | \pnum
|
5717 |
| -\effects |
5718 |
| -The iterator is destroyed. |
| 5683 | +\remarks |
5719 | 5684 | If \tcode{is_trivially_destructible_v<T>} is \tcode{true},
|
5720 | 5685 | then this destructor is trivial.
|
5721 | 5686 | \end{itemdescr}
|
|
5728 | 5693 | \end{itemdecl}
|
5729 | 5694 |
|
5730 | 5695 | \begin{itemdescr}
|
| 5696 | +\pnum |
| 5697 | +\expects |
| 5698 | +\tcode{in_stream != nullptr} is \tcode{true}. |
| 5699 | + |
5731 | 5700 | \pnum
|
5732 | 5701 | \returns
|
5733 | 5702 | \tcode{value}.
|
|
5739 | 5708 | \end{itemdecl}
|
5740 | 5709 |
|
5741 | 5710 | \begin{itemdescr}
|
| 5711 | +\pnum |
| 5712 | +\expects |
| 5713 | +\tcode{in_stream != nullptr} is \tcode{true}. |
| 5714 | + |
5742 | 5715 | \pnum
|
5743 | 5716 | \returns
|
5744 |
| -\tcode{addressof(operator*())}. |
| 5717 | +\tcode{addressof(value)}. |
5745 | 5718 | \end{itemdescr}
|
5746 | 5719 |
|
5747 | 5720 | \indexlibrarymember{operator++}{istream_iterator}%
|
|
5751 | 5724 |
|
5752 | 5725 | \begin{itemdescr}
|
5753 | 5726 | \pnum
|
5754 |
| -\requires \tcode{in_stream != nullptr}. |
| 5727 | +\expects |
| 5728 | +\tcode{in_stream != nullptr} is \tcode{true}. |
5755 | 5729 |
|
5756 | 5730 | \pnum
|
5757 |
| -\effects |
5758 |
| -As if by: \tcode{*in_stream >> value;} |
| 5731 | +\effects Equivalent to: |
| 5732 | +\begin{codeblock} |
| 5733 | +if (!(*in_stream >> value)) |
| 5734 | + in_stream = nullptr; |
| 5735 | +\end{codeblock} |
5759 | 5736 |
|
5760 | 5737 | \pnum
|
5761 | 5738 | \returns
|
|
5769 | 5746 |
|
5770 | 5747 | \begin{itemdescr}
|
5771 | 5748 | \pnum
|
5772 |
| -\requires \tcode{in_stream != nullptr}. |
5773 |
| - |
5774 |
| -\pnum |
5775 |
| -\effects |
5776 |
| -As if by: |
| 5749 | +\effects Equivalent to: |
5777 | 5750 | \begin{codeblock}
|
5778 | 5751 | istream_iterator tmp = *this;
|
5779 |
| -*in_stream >> value; |
| 5752 | +++*this; |
5780 | 5753 | return tmp;
|
5781 | 5754 | \end{codeblock}
|
5782 | 5755 | \end{itemdescr}
|
|
0 commit comments