Re: const and proxies of objects
* Kai-Uwe Bux, on 03.06.2010 19:45:
... (Beware: int may not be
universally appropriate, e.g., for file-backed containers std::streamoff
might be appropriate; and that is larger than int on some systems.)
prtdiff_t covers most of it in practice on current desktop systems for in-memory
containers.
This means simpler code: you don't have to care about or adapt client code to
the type.
stream positions are a special case on 32-bit systems. Since standard arithmetic
doesn't generally suffice a simple typedef is of dubious advantage. I'd say
negative advantage...
<quote
src="http://www.boost.org/doc/libs/1_43_0/libs/iostreams/doc/functions/positioning.html"
emphasis="mine">
The header <boost/iostreams/positioning.hpp> provides the definition of the
integral type boost::iostreams::stream_offset, capable of holding arbitrary
stream offsets on most platforms, together with the definition of two functions,
offset_to_position and position_to_offset, for converting between stream_offset
and std::streampos.
The type std::streampos is required to be able to hold an arbitrary stream
position, but it is not an intergral type. Although std::streampos is
interconvertible with the integral type std::streamoff, the conversion from
std::streampos to std::streamoff *may not be faithful* for large (64-bit)
values. The integral type boost::iostreams::stream_offset is intended as a
replacement for std::streamoff, with the implicit conversions to and from
std::streampos being replaced by explicit conversion functions.
The implementation of offset_to_position and position_to_offset relies on
implementation defined behavior, and is guaranteed to work correctly for large
values only for standard libraries which define std::streamoff to be 64-bit type
or for which the Boost Iostreams library has been explicitly configured.
</quote>
Cheers & hth.,
- Alf
--
blog at <url: http://alfps.wordpress.com>