State state() const; | (1) | |
void state( State st ); | (2) |
Manages the file position state.
st.For the specializations of std::fpos that are used in the standard library, State is always std::mbstate_t.
| st | - | new value for the state |
fpos state#include <iostream>
#include <sstream>
#include <cwchar>
int main()
{
std::istringstream s("test");
std::mbstate_t st = s.tellg().state();
if (std::mbsinit(&st))
std::cout << "The stream is in the initial shift state\n";
}Output:
The stream is in the initial shift state
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 441 | C++98 | overload (1) was not declared const (it is const in the synopsis) | added const |
| conversion state information necessary to iterate multibyte character strings (class) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/io/fpos/state