From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77122 invoked by alias); 21 Aug 2019 19:38:43 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 77114 invoked by uid 89); 21 Aug 2019 19:38:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=evil X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 21 Aug 2019 19:38:41 +0000 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49D6285365 for ; Wed, 21 Aug 2019 19:38:40 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id k14so1703884wrv.2 for ; Wed, 21 Aug 2019 12:38:40 -0700 (PDT) Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id e11sm59961699wrc.4.2019.08.21.12.38.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Aug 2019 12:38:38 -0700 (PDT) Subject: Re: [PATCH] Remove some variables in favor of using gdb::optional To: Simon Marchi , gdb-patches@sourceware.org References: <20190804201023.25628-1-simon.marchi@polymtl.ca> From: Pedro Alves Message-ID: <9b1cdf6d-baae-3a5e-c2ea-fcdf124b7a1b@redhat.com> Date: Wed, 21 Aug 2019 19:38:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190804201023.25628-1-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-08/txt/msg00512.txt.bz2 On 8/4/19 9:10 PM, Simon Marchi wrote: > - bool have_is_static = false; > - bool is_static; > + gdb::optional is_static; std::optional 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