Date: Mon, 12 May 2025 23:28:56 +0300
I agree I have had bug where I was doing:
void set_property(const char *name, const char *default_value);
void set_property_bool(const char*name, bool default_value);
And so I was calling the first with:
set_property("prop", "true")
But then when I call the second version with
set_property_bool("prop", "true")
It compiles fine and even works as expected until I changed it to
set_property_bool("prop", "false")
And then I banged my head for a while.
I also agree this was probably a bad design also but still.
On Mon, May 12, 2025 at 5:34 PM Jonathan Wakely via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Mon, 12 May 2025 at 15:21, Tymi via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > I think pointer == bool should be permitted
> > For instance
> > `if (myPointer == false) throw nullptr;`
>
>
> This goes in the opposite direction from improvements made since
> C++98, which permitted pointers to be initialized with any integral
> constant (including false). Now we only allow literal zero as a null
> pointer constant, not any constant with value zero.
>
> I don't see any reason to treat false as a pointer value.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
void set_property(const char *name, const char *default_value);
void set_property_bool(const char*name, bool default_value);
And so I was calling the first with:
set_property("prop", "true")
But then when I call the second version with
set_property_bool("prop", "true")
It compiles fine and even works as expected until I changed it to
set_property_bool("prop", "false")
And then I banged my head for a while.
I also agree this was probably a bad design also but still.
On Mon, May 12, 2025 at 5:34 PM Jonathan Wakely via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Mon, 12 May 2025 at 15:21, Tymi via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > I think pointer == bool should be permitted
> > For instance
> > `if (myPointer == false) throw nullptr;`
>
>
> This goes in the opposite direction from improvements made since
> C++98, which permitted pointers to be initialized with any integral
> constant (including false). Now we only allow literal zero as a null
> pointer constant, not any constant with value zero.
>
> I don't see any reason to treat false as a pointer value.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-05-12 20:29:12