Question: Currently I have a scenario where I want to check whether writing a given string to a filestream will grow the file beyond a given size (this is used for logfile rotation). Now, `std::ofstream::tellp()` returns a `streampos`, but `std::string::size()` returns a `size_t`. The effect is, that this does not work:

```
out_stream.tellp() + string.size() < limit

```

because apparently there is an ambiguous overload of `operator +` for these types. This leads me to two questions:

1. How can I resolve the above ambiguity?
2. How do all the different types (`size_t`, `streamsize`, `streampos`, `streamoff`) relate to each other? When can they be safely converted, and what are possible pitfalls. I am generally confused about these types. All I know is that they are implementation dependent, and that they make certain guarantees (e.g. `size_t` is always large enough to hold the size of the larges object that would fit into memory on the architecture for which the application was compiled), but what are the guarantees concerning interoperability of these types (see example above, or comparing a `streamsize` to a `size_t`)?

Answer: 
You should be able to convert the result from tellp to a `std::string::size_type` by casting.

`static_cast<std::string::size_type>(out_stream.tellp()) + string.size() < limit`

EDIT: This is safe because your stream offset will never be negative and will safely convert to an unsigned value.
If you have big sizes, isn't **unsigned long long** the best you can get. If that isn't big enough, what else is?