std::basic_istream<CharT,Traits>::gcount

Returns the number of characters extracted by the last unformatted input operation, or the maximum representable value of std::streamsize if the number is not representable.

# Declarations

std::streamsize gcount() const;

# Return value

The number of characters extracted by the last unformatted input operation, or the maximum representable value of std::streamsize if the number is not representable.

# Example

#include <iostream>
#include <sstream>
 
int main()
{
    char x[20];
    std::istringstream stream("Hello World");
 
    stream.read(x, sizeof x);
    std::cout << "Characters extracted: " << stream.gcount();
}

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 3464C++98the return value was unspecified when the result overflowsreturns the maximum value