This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Remove some variables in favor of using gdb::optional
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>, gdb-patches at sourceware dot org
- Date: Wed, 21 Aug 2019 20:38:37 +0100
- Subject: Re: [PATCH] Remove some variables in favor of using gdb::optional
- References: <20190804201023.25628-1-simon.marchi@polymtl.ca>
On 8/4/19 9:10 PM, Simon Marchi wrote:
> - bool have_is_static = false;
> - bool is_static;
> + gdb::optional<bool> is_static;
std::optional<bool> is evil. :-)
E.g. it's very easy to write (or miss converting)
if (is_static)
and not realize that that is doing the wrong thing.
https://www.boost.org/doc/libs/1_57_0/libs/optional/doc/html/boost_optional/tutorial/a_note_about_optional_bool_.html
Not saying to change the code (*), but seeing it gives me the creeps, so I couldn't resist. :-)
* - a yes/no/unknown tristate type a-la boost::tribool would be nice
to have, IMO. It could be used more clearly in these situations
and could supersede auto_boolean.
Thanks,
Pedro Alves