Search code examples
c++iostreamiomanip

Check if skipws/noskipws flag is set for an input stream


In order to set the std::skipws (or std::noskipws) flag, one needs to write:

my_input_stream >> std::skipws; //or my_input_stream >> std::noskipws;

But how do I check if the flag is set? I need to enable noskipws for my operator >> , but I want to restore the previously set value after. I am aware of boost I/O state savers, but I need to do a demonstration for students and using boost might be overkill for this simple purpose.


Solution

  • You're looking for std::ios_base::flags() :)