Well, as for C ++ 98/03, there is no long long int . Therefore, I assume that you are asking about C ++ 11.
streamsize and streamoff must be integer typedefs ( streampos not an integer, so you wonโt pass this to anything that takes long long ). Since integral types are basic types, they can only be defined using C ++ or as a definition specific to the compiler.
So the only question is: are these typedefs bigger than long long ? All integral types are converted to a larger or equal size (regardless of the subscription / unsigned, but all types are signed here, so there are no problems). But if he is more ... what are you going to do about it?
Assuming that you cannot change the signature of the function into which you inject it (because, if you could, there is no reason to not just accept streamsize as the type of the parameter and therefore avoid the problem), you donโt have any options . You have a data value that is more than a function. There is no way around this.
You can execute static_cast in long long to close the compiler, but this will not help if the actual size cannot be placed in long long .
Ultimately, this is an insoluble problem. You have a function that takes a parameter that is potentially too small for what you are passing. The most you can do is discover when this can be a problem with static_assert . Something like that:
static_assert(sizeof(std::streamsize) <= sizeof(long long), "Oops.");
To be honest, I would not worry about that. The odds are good because long long will be the largest integral size your compiler supports.
Nicol bolas
source share