A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FSTL_Algorithms_Iterator%2Fistream_iterator</id>
		<title>C++ Tutorial/STL Algorithms Iterator/istream iterator - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FSTL_Algorithms_Iterator%2Fistream_iterator"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Algorithms_Iterator/istream_iterator&amp;action=history"/>
		<updated>2026-04-10T21:50:18Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Algorithms_Iterator/istream_iterator&amp;diff=2353&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Algorithms_Iterator/istream_iterator&amp;diff=2353&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Algorithms_Iterator/istream_iterator&amp;diff=2354&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/STL_Algorithms_Iterator/istream_iterator&amp;diff=2354&amp;oldid=prev"/>
				<updated>2010-05-25T10:29:31Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Advance istream_iterator==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    istream_iterator&amp;lt;string&amp;gt; cinPos(cin);&lt;br /&gt;
    ostream_iterator&amp;lt;string&amp;gt; coutPos(cout,&amp;quot; &amp;quot;);&lt;br /&gt;
    /* while input is not at the end of the file&lt;br /&gt;
     * - write every third string&lt;br /&gt;
     */&lt;br /&gt;
    while (cinPos != istream_iterator&amp;lt;string&amp;gt;()) {&lt;br /&gt;
        // ignore the following two strings&lt;br /&gt;
        advance (cinPos, 2);&lt;br /&gt;
        // read and write the third string&lt;br /&gt;
        if (cinPos != istream_iterator&amp;lt;string&amp;gt;()) {&lt;br /&gt;
            *coutPos++ = *cinPos++;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Terminate batch job (Y/N)? n&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==istream_iterator reads and displays characters from cin until a period is received.==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
   &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  istream_iterator&amp;lt;char&amp;gt; in_it(cin);&lt;br /&gt;
   &lt;br /&gt;
  do {&lt;br /&gt;
    cout &amp;lt;&amp;lt; *in_it++;&lt;br /&gt;
  } while (*in_it != &amp;quot;.&amp;quot;);&lt;br /&gt;
   &lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Read string from keyboard and save to vector directly==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;istream&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;functional&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main( ) {&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Enter a series of strings: &amp;quot;;&lt;br /&gt;
   istream_iterator&amp;lt;string&amp;gt; start(cin);&lt;br /&gt;
   istream_iterator&amp;lt;string&amp;gt; end;&lt;br /&gt;
   vector&amp;lt;string&amp;gt; v(start, end);&lt;br /&gt;
   vector&amp;lt;string&amp;gt;::iterator p = partition(v.begin( ), v.end( ),bind2nd(less&amp;lt;string&amp;gt;( ), &amp;quot;foo&amp;quot;));&lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;*p = &amp;quot; &amp;lt;&amp;lt; *p &amp;lt;&amp;lt; endl;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Enter a series of strings: a b c&lt;br /&gt;
a s c&lt;br /&gt;
de&lt;br /&gt;
foo&lt;br /&gt;
*p = s&lt;br /&gt;
Terminate batch job (Y/N)? n&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Read words from standard input, sort and print out without duplicates==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;/* The following code example is taken from the book&lt;br /&gt;
 * &amp;quot;The C++ Standard Library - A Tutorial and Reference&amp;quot;&lt;br /&gt;
 * by Nicolai M. Josuttis, Addison-Wesley, 1999&lt;br /&gt;
 *&lt;br /&gt;
 * (C) Copyright Nicolai M. Josuttis 1999.&lt;br /&gt;
 * Permission to copy, use, modify, sell and distribute this software&lt;br /&gt;
 * is granted provided this copyright notice appears in all copies.&lt;br /&gt;
 * This software is provided &amp;quot;as is&amp;quot; without express or implied&lt;br /&gt;
 * warranty, and with no claim as to its suitability for any purpose.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;algorithm&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using namespace std;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    vector&amp;lt;string&amp;gt; coll;&lt;br /&gt;
    /* read all words from the standard input&lt;br /&gt;
     * - source: all strings until end-of-file (or error)&lt;br /&gt;
     * - destination: coll (inserting)&lt;br /&gt;
     */&lt;br /&gt;
    copy (istream_iterator&amp;lt;string&amp;gt;(cin),    // start of source&lt;br /&gt;
          istream_iterator&amp;lt;string&amp;gt;(),       // end of source&lt;br /&gt;
          back_inserter(coll));             // destination&lt;br /&gt;
    // sort elements&lt;br /&gt;
    sort (coll.begin(), coll.end());&lt;br /&gt;
    /* print all elements without duplicates&lt;br /&gt;
     * - source: coll&lt;br /&gt;
     * - destination: standard output (with newline between elements)&lt;br /&gt;
     */&lt;br /&gt;
    unique_copy (coll.begin(), coll.end(),             // source&lt;br /&gt;
                 ostream_iterator&amp;lt;string&amp;gt;(cout,&amp;quot;\n&amp;quot;)); // destination&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;a b c&lt;br /&gt;
de&lt;br /&gt;
d&lt;br /&gt;
s&lt;br /&gt;
s&lt;br /&gt;
e&lt;br /&gt;
w&lt;br /&gt;
d&lt;br /&gt;
a&lt;br /&gt;
b&lt;br /&gt;
c^CTerminate batch job (Y/N)? n&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Taking the sum of values from a stream==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
using std::cin;&lt;br /&gt;
using std::istream_iterator;&lt;br /&gt;
template &amp;lt;typename Iter&amp;gt; &lt;br /&gt;
double mySum (Iter begin, Iter end) { &lt;br /&gt;
  double sum = 0.0;&lt;br /&gt;
  &lt;br /&gt;
  for( ; begin != end ;)&lt;br /&gt;
    sum += *begin++;&lt;br /&gt;
  return sum;&lt;br /&gt;
} &lt;br /&gt;
int main() {&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Ctrl-Z to stop&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
  double av = mySum(istream_iterator&amp;lt;double&amp;gt;(cin), istream_iterator&amp;lt;double&amp;gt;());&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;The sum value is &amp;quot; &amp;lt;&amp;lt; av &amp;lt;&amp;lt; endl;&lt;br /&gt;
return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Ctrl-Z to stop&lt;br /&gt;
^Z&lt;br /&gt;
The sum value is 0&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use istream_iterator to loop through a string==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt; &lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
using std::istream_iterator;&lt;br /&gt;
using std::istringstream;&lt;br /&gt;
using std::string;&lt;br /&gt;
template &amp;lt;typename Iter&amp;gt; &lt;br /&gt;
double mySum(Iter begin, Iter end) { &lt;br /&gt;
  double sum = 0.0;&lt;br /&gt;
  &lt;br /&gt;
  for( ; begin != end ;)&lt;br /&gt;
    sum += *begin++;&lt;br /&gt;
  return sum;&lt;br /&gt;
} &lt;br /&gt;
int main() {&lt;br /&gt;
  std::string stock_ticker = &amp;quot;4.5 6.75 8.25 7.5 5.75&amp;quot;;&lt;br /&gt;
  istringstream ticker(stock_ticker);&lt;br /&gt;
  istream_iterator&amp;lt;double&amp;gt; begin(ticker);&lt;br /&gt;
  istream_iterator&amp;lt;double&amp;gt; end;&lt;br /&gt;
  cout &amp;lt;&amp;lt; stock_ticker &amp;lt;&amp;lt; endl ;&lt;br /&gt;
  &lt;br /&gt;
  cout &amp;lt;&amp;lt; mySum (begin, end) &amp;lt;&amp;lt; endl; &lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;4.5 6.75 8.25 7.5 5.75&lt;br /&gt;
32.75&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use istream_iterator to loop through a string defined by char pointer==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iterator&amp;gt; &lt;br /&gt;
#include &amp;lt;string&amp;gt;&lt;br /&gt;
#include &amp;lt;sstream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
using std::istream_iterator;&lt;br /&gt;
using std::istringstream;&lt;br /&gt;
using std::string;&lt;br /&gt;
template &amp;lt;typename Iter&amp;gt; &lt;br /&gt;
double mySum(Iter begin, Iter end) { &lt;br /&gt;
  double sum = 0.0;&lt;br /&gt;
  &lt;br /&gt;
  for( ; begin != end ;)&lt;br /&gt;
    sum += *begin++;&lt;br /&gt;
  return sum;&lt;br /&gt;
} &lt;br /&gt;
int main() {&lt;br /&gt;
  char* stock_ticker = &amp;quot;4.5 6.75 8.25 7.5 5.75&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  istringstream ticker(stock_ticker);&lt;br /&gt;
  istream_iterator&amp;lt;double&amp;gt; begin(ticker);&lt;br /&gt;
  istream_iterator&amp;lt;double&amp;gt; end;&lt;br /&gt;
  cout &amp;lt;&amp;lt; stock_ticker &amp;lt;&amp;lt; endl ;&lt;br /&gt;
  &lt;br /&gt;
  cout &amp;lt;&amp;lt; mySum (begin, end) &amp;lt;&amp;lt; endl; &lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;4.5 6.75 8.25 7.5 5.75&lt;br /&gt;
32.75&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>