This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] err |= ios_base::failbit or err = ios_base::failbit?!?
Martin Sebor <sebor@roguewave.com> writes:
| Nathan Myers wrote:
|
| ...
| >>That will be the case with num_get
| >>and money_get, but not time_get. Another problem is that the
| >>caller might leave the iostate variable uninitialized, and
| >>expect the get() member function to set it regardless of
| >>whether it succeeds or not. That seems to be the case with
| >>num_get but not the other facets.
| > Right. But generally, initialization is supposed to be the
| > responsibility of the owner of the object, e.g. whoever created it.
|
| Yes, I agree with this policy in general. In the case of functions
| whose performance is critical, though, it may, IMHO, be quite
| appropriate to violate it by allowing callers to pass uninitialized
| iostate by requiring the get() members to always set its value. Not
It is not obvious to me that, in the large this is a real win and that
it worths breaking existing semantics.
| only could it save a CPU cycle or two, but it would also make the
| get functions more robust in the presence of user errors. Unless
| you or someone else objects to a change to the text that would
| codify this policy I will write up an issue and propose that all
| facets, not just num_get, behave this way.
-- Gaby