Is std::streampos source-compatible with std::ios_base::streampos?

Viewed 93

I am managing a codebase that makes use of std::ios_base::streampos (specifically, the tellg() method of input streams) in a header file, that's included in several other files, and as expected, the compiler is making a lot of warnings about its deprecation, and how I should use std::streampos instead.

Is std::streampos just something I can replace the variable and function types with? Or does it remove methods or modify method functionality from std::ios_base::streampos?

The C++ class documentation for ios_base says:

streampos(deprecated) unspecified type that may be used like pos_type, not necessarily std::streampos

Does this mean std::ios_base::streampos is functionally equivalent to std::ios_base::pos_type (which itself is std::fpos<std::mbstate_t>) and by extension std::streampos?

1 Answers

The direct replacement (std::ios_base::streampos was removed in C++17) is std::basic_ios::pos_type; there is no std::ios_base::pos_type, since ios_base is shared by all character types. For std::char_traits<char>, that is indeed std::streampos.

Related