This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] Large file iostreams
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 13 Oct 2003 09:43:42 -0000
- Subject: [RFC] Large file iostreams
Hi,
This was discussed in July in the thread starting at:
http://gcc.gnu.org/ml/libstdc++/2003-07/msg00108.html
It was agreed that streamoff needs to be a class type that
encapsulates a 64-bit integer and that this change needs to be made
before gcc 3.4 is released.
The best I can come up with is something like this:
// A signed integer type, at least 64-bits wide
typedef /* ... */ __streamoff_base_type;
class streamoff
{
public:
streamoff();
streamoff(__streamoff_base_type); // Implicit
template<typename _StateT>
explicit streamoff(const fpos<_StateT>&);
operator __streamoff_base_type() const;
streamoff& operator+=(__streamoff_base_type);
streamoff& operator-=(__streamoff_base_type);
};
There are no non-member operators, expressions such as __off != 0 or
__off * __width (used in basic_filebuf::seekoff) use the conversion
to __streamoff_base_type. fpos is mostly unchanged except that
operator streamoff() is removed.
There are obvious problems with this implementation, in particular
the implicit conversions to and from __streamoff_base_type mean that
there is very little type safety. However, there is type safety
where it matters most: there are no implicit conversions from
fpos to integer types.
Does anybody know of a way to make the conversion to streamsize
explicit? Type safety would be much improved.
Should other operators be added? The implicit conversion provides
most arithmetic operators, but ++, --, *= and /= are missing (and
probably some more).
What should __streamoff_base_type be? Is long long "good enough"
or should it be platform specific?
Should fpos::fpos(streamoff) be explicit? It is a lossless
conversion and the conversion from int must be implicit so it
doesn't add much type safety.
Regards,
Petur