From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by sourceware.org (Postfix) with ESMTPS id 5CFEB3857806 for ; Wed, 16 Mar 2022 09:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5CFEB3857806 Received: by mail-io1-xd2e.google.com with SMTP id d62so1603945iog.13 for ; Wed, 16 Mar 2022 02:31:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tukkK7j79YuD4UcsZacbp+tfYdNiVhrsTfuimxQGWH8=; b=QJ21c+7fNawW1RVJllvS8CDoNvHSXVl3/19SiHpHtpZD3KpgKnh6g8a/qwIGj+vnbA qpJTZ4Y5sb4IKQwfv+Zu78ZaVDaHyVmldZwoogHG5PRDuDOw4mfC9MoOz1AwS5ocvG6o yhmzMCMl+dj5dbiiJbNc/qHXTI3fiugYSEutZx1fkAz6Ca4g6OvFuMJVV/EC1ZjXA59b w69ROHgPaV/KCCXxIXDCtzNF6oSbmnqGAWKB8RfEF90cGpOalAyzV1iuNY8yAzlowWzg W1WBv1XoiKDp69xWcqxZSPYO01yTNK1e3zIoDUmLrVlgKRdNqacmbtYxz8X13l3xatNT OzVg== X-Gm-Message-State: AOAM532MdzHLS6EfD3mc+qFHzi6imt43I1s8aX3FWtEdF0dni/v288o9 0/6YMdMcow6oC9KrtzY7nOIluBI8efRJR03ep9EK1A== X-Google-Smtp-Source: ABdhPJxkNBB1Iy1Debu23u7HZC5MP07EmGX8z3YLIiW5nUIMAi1alRjo9toI+NkcPjWZNrdHwpxKmgE4I7ATiP1ROSw= X-Received: by 2002:a6b:b3d4:0:b0:641:ea9:78ed with SMTP id c203-20020a6bb3d4000000b006410ea978edmr23830260iof.21.1647423114521; Wed, 16 Mar 2022 02:31:54 -0700 (PDT) MIME-Version: 1.0 References: <20220314181312.3436802-1-gprocida@google.com> <20220314181312.3436802-2-gprocida@google.com> In-Reply-To: From: Giuliano Procida Date: Wed, 16 Mar 2022 09:31:18 +0000 Message-ID: Subject: Re: [PATCH 1/2] optional: add operator== and operator!= To: Matthias Maennich Cc: libabigail@sourceware.org, dodji@seketeli.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-27.8 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Mar 2022 09:31:57 -0000 Hi. On Tue, 15 Mar 2022 at 11:02, Matthias Maennich wrote: > > On Mon, Mar 14, 2022 at 06:13:11PM +0000, Giuliano Procida wrote: > > * include/abg-cxx-compat.h (optional): Add operator== and > > operator!=. > > > >Signed-off-by: Giuliano Procida > >--- > > include/abg-cxx-compat.h | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > >diff --git a/include/abg-cxx-compat.h b/include/abg-cxx-compat.h > >index 443905c7..a2cf9095 100644 > >--- a/include/abg-cxx-compat.h > >+++ b/include/abg-cxx-compat.h > >@@ -91,6 +91,22 @@ public: > > } > > > > explicit operator bool() const { return has_value_; } > > std signature is (at least make it noexcept): > > constexpr explicit operator bool() const noexcept; > Will do. I could add some, but not all, the constexpr as C++11 complains about ambiguous overloads. > >+ > >+ bool > >+ operator==(const optional& other) const > >+ { > >+ if (!has_value_ && !other.has_value_) > >+ return true; > >+ if (!has_value_ || !other.has_value_) > >+ return false; > >+ return value_ == other.value_; > >+ } > >+ > >+ bool > >+ operator!=(const optional& other) const > >+ { > >+ return !operator==(other); > >+ } > > I believe C++17 defines those as non-member functions. Should we follow > that for compatibility. Eventually, when switching to C++17 or later we > would want to just replace abg_compat:: with std:: and things should > "just work". > Sure. > Cheers, > Matthias > v2 will follow. Giuliano. > > }; > > > > #endif > >-- > >2.35.1.723.g4982287a31-goog > >