Re: void * instead of bool
From: Alf P. Steinbach (alfps_at_start.no)
Date: 06/21/04
- Next message: David Rubin: "Re: Determining array size"
- Previous message: Default User: "Re: Assumptions About the Size of Integer Types"
- In reply to: Karl Heinz Buchegger: "Re: void * instead of bool"
- Next in thread: Andrew Koenig: "Re: void * instead of bool"
- Reply: Andrew Koenig: "Re: void * instead of bool"
- Reply: Rob Williscroft: "Re: void * instead of bool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 21 Jun 2004 18:09:47 GMT
* Karl Heinz Buchegger:
> Marcin Kalicinski wrote:
> >
> > Hi,
> >
> > Why is there void* conversion to check for std::istream failure bit? Why not
> > a conversion to bool?
>
> Because you definitily don't want this to compile:
>
> ifstream if;
> int j;
>
> j = 2 + if;
Assuming you meant to use a non-keyword instead of "if", _why_ on or off
Earth would I definitily (?) not want that to compile?
The same goes for Andrew's example.
On the contrary, a good design does not needlessly limit the user to
do only things the designer is able to foresee the usefulness of.
I think there are two more realistic explanations.
One is that perhaps the original design dates from a time before 'bool'
was introduced in the language. Another is that perhaps there is some
subtle issue with e.g. function overload resolution, e.g. passing an
ifstream object to a constructor where one overload takes a bool. In
the latter case (which does not exclude the first) the conversion to
void* is already one conversion, and void* is a very unspecific type, so
a direct conversion to a more sensible type would, ideally, be chosen.
-- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
- Next message: David Rubin: "Re: Determining array size"
- Previous message: Default User: "Re: Assumptions About the Size of Integer Types"
- In reply to: Karl Heinz Buchegger: "Re: void * instead of bool"
- Next in thread: Andrew Koenig: "Re: void * instead of bool"
- Reply: Andrew Koenig: "Re: void * instead of bool"
- Reply: Rob Williscroft: "Re: void * instead of bool"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|