This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Remove some variables in favor of using gdb::optional


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]