Size of a FILE ADDRESS in c++

How does one determine the sizeof a pos_type or offset_type such as is used in c++ stream i/o. You can't just write sizeof(pos_type) or sizeof(basic_streambuf::pos_type) because it is defined somehow inside a template that ... well, it's pretty complex.

It would be nice to know this at compile time.

BTW, there is a type called "streamsize" that seems to fit the bill, but sizeof(streamsize) is not a valid preprocessor term.

1 c++
13.10.2009 18:02:56
2 ОТВЕТА

basic_streambuf is a template class. It is not fully defined until you use it. Use sizeof for members of template specialization, e.g. for streambuf::pos_type.

0
13.10.2009 18:38:07
Well, what I get is 24 if I say sizeof(streambuf::pos_type) or if I say streambuf::pos_type x; cout << sizeof(x) .... So, pos_type is some kind of class that can convert to an integer or something, but it is PROBABLY NOT a 24-byte file-address, if I'm not mistaken. Please forgive me. It's been a while since I've done much c++.
user189321 13.10.2009 19:46:23

You need to use sizeof on an instantiation of the template. sizeof(ifstream::pos_type)

1
13.10.2009 18:36:16
Well, what I get is 24 if I say sizeof(streambuf::pos_type) or if I say streambuf::pos_type x; cout << sizeof(x) .... So, pos_type is some kind of class that can convert to an integer or something, but it is PROBABLY NOT a 24-byte file-address, if I'm not mistaken. Please forgive me. It's been a while since I've done much c++.
user189321 13.10.2009 19:46:54
If sizeof(T) is 24, then T is a 24 byte type. That's pretty much the definition of sizeof and byte in C++.
MSalters 14.10.2009 08:46:12