What you're probably referring to is foo.rdbuf()->in_avail(), but you have made the incorrect assumption that a stream always holds its entire contents in the buffer, which isn't going to be the case for things like file streams.
GCC for instance uses a buffer of length BUFSIZ which will be at least 256 bytes (it's 1024 on my system), so any file larger than that cannot be held entirely in a basic_filebuf's buffer.
There's no portable way to get the true size of a stream, for instance a stream opened in text mode on windows won't give you the actual number of bytes in the stream because of EOL conversion. Streams are designed to be read from until you hit the end, depending on what you're trying to do with the stream there may be a better way.
Source-wise any introductory C++ book will tell you as much, but here's the relevant wording in the standard
[streambuf.reqts]
Each sequence is characterized by three pointers which, if non-null, all point into the same charT array object. The array object represents, at any moment, a (sub)sequence of characters from the sequence.
fooexactly? If it is a file stream, do you expect it to have the entire file buffered in memory at one time? Depending on the stream type, a seek is required.