how does istringstream operator>> return value work?
<p>This example reads lines with an integer, an operator, and another integer. For example,</p>

<h2>25 * 3</h2>

<h2>4 / 2</h2>

<pre><code>// sstream-line-input.cpp - Example of input string stream.
//          This accepts only lines with an int, a char, and an int.
// Fred Swartz 11 Aug 2003

#include &lt;iostream&gt;
#include &lt;sstream&gt;
#include &lt;string&gt;
using namespace std;
//================================================================ main
int main() {
    string s;                 // Where to store each line.
    int    a, b;              // Somewhere to put the ints.
    char   op;                // Where to save the char (an operator)
    istringstream instream;   // Declare an input string stream

    while (getline(cin, s)) { // Reads line into s
        instream.clear();     // Reset from possible previous errors.
        instream.str(s);      // Use s as source of input.
        if (instream &gt;&gt; a &gt;&gt; op &gt;&gt; b) {
            instream &gt;&gt; ws;        // Skip white space, if any.
            if (instream.eof()) {  // true if we're at end of string.
                cout &lt;&lt; "OK." &lt;&lt; endl;
            } else {
                cout &lt;&lt; "BAD. Too much on the line." &lt;&lt; endl;
            }
        } else {
            cout &lt;&lt; "BAD: Didn't find the three items." &lt;&lt; endl;
        }
    }
    return 0;
}
</code></pre>

<p><code>operator&gt;&gt;</code>Return the object itself (*this).</p>

<p>How does the test <code>if (instream &gt;&gt; a &gt;&gt; op &gt;&gt; b)</code> work?</p>

<p>I think the test always <code>true</code>, because <code>instream!=NULL</code>.</p>
