Search code examples
c++ifstream

What is the difference between std::ifstream::in and std::ios::in? (obviously as an openmode flag for an std::ifstream in C++)


I used SymbolHound to look for ressources on the web comparing the two but couldn't find anything.

Looking for std::ifstream::in's declaration and definition in VS13 brings me to basic_ifstream's. Looking for std::ios::in's brings me to basic_ios's.

It seems std::ios::in is more widely used.

Thanks in advance,

Hans


Solution

  • They are both the same.

    in is a member of std::ios_base. It's therefore also a member of ios, ifstream, and everything else that derives from ios_base.

    It seems std::ios::in is more widely used.

    Probably because that's the shortest way to name it.