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 2019-08-21 3:38 p.m., Pedro Alves wrote:
> 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

Oh, thanks for pointing out.  I had never realized this but it makes sense.  There should be a compiler
warning about it!  Or maybe it would belong to a linter.

I'll look into adding a tristate bool and fixing it.

Simon


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