This function overloads the global operator>> to behave as described in istream::operator>> but applied to string objects.
Notice that the istream extraction operations use whitespaces as separators, therefore this operation will only extract what can be considered a word from the stream. To extract entire lines of text, refer to the string overload of global function getline.
Parameters
- is
- istream object on which the extraction operation is performed.
- str
- string object where the extracted content is stored.
Return Value
The same as parameter is.Errors are signaled by modifying the internal state flags:
| flag | error |
|---|---|
| eofbit | The end of the source of characters is reached during its operations. |
| failbit | The input obtained could not be interpreted as an element of the appropriate type. Notice that some eofbit cases will also set failbit. |
| badbit | An error other than the above happened. |
(see ios_base::iostate for more info on these)
Additionaly, in any of these cases, if the appropriate flag has been set with is's member function ios::exceptions, an exception of type ios_base::failure is thrown.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Basic template declaration
| 1 2 3 4 |
|
See also
| istream::operator>> | Extract formatted data (public member function) |
| getline | Get line from stream (function) |
| operator<< | Insert string into stream (function) |
