From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 7C30F3858D28 for ; Tue, 15 Mar 2022 11:02:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C30F3858D28 Received: by mail-wr1-x433.google.com with SMTP id e24so28311489wrc.10 for ; Tue, 15 Mar 2022 04:02:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NTQaBbBx9tPbxYS//TePhQmGnBTpf9a2NuPFe8d2DYQ=; b=dqjb/SqzTbjrLZl7uhZjWlR9G1nl0YGQW9lp2wJj4PKBSL+F5TRsUYSwt/xPHIYWU/ F+gEQIGB77iWrtTTtGhf1Wje+8j6G0alGqriKvhxpy6zt1HRoSMHGUYQqyRzm5BJEPgt QxzBecQhxDq5aQV50/GCGiIaDTOYI/YEWXxP/yiu5eaXkVwIpZjkt9W+1a6EeNSK6SVZ iACPKXYxNMuLo0FYToQFP33XkgieAoSfCw6dDobWUaqav+zq6NCCXJrbvx+aC75yvRwn 4Dq0G02oIZMRaQHBgFoPHSvBe/kCn2cTsAHh5oKUM3UNEZUpYR/6SIfL5gVBYKGbkoHN 0rug== X-Gm-Message-State: AOAM530L3I8LCf5LqLo2fjXZSXhGwMwrqYmXre4Sz/3RkYQpgPo+GhNt +9XKFlEEffA2LBh3/gR5M3a77g== X-Google-Smtp-Source: ABdhPJwbKv3UKsCYZSVlNVtixy3eviSuXAQyjE6RHuRwPySyPNceMArZbzRI9V9jaPZbJ9VE9ZR0zw== X-Received: by 2002:a5d:4387:0:b0:1ed:a13a:ef0c with SMTP id i7-20020a5d4387000000b001eda13aef0cmr19802400wrq.62.1647342166699; Tue, 15 Mar 2022 04:02:46 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:bca7:203f:7a8f:510]) by smtp.gmail.com with ESMTPSA id o20-20020a05600c4fd400b00389ded79198sm2174074wmq.34.2022.03.15.04.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 04:02:46 -0700 (PDT) Date: Tue, 15 Mar 2022 11:02:45 +0000 From: Matthias Maennich To: Giuliano Procida Cc: libabigail@sourceware.org, dodji@seketeli.org, kernel-team@android.com Subject: Re: [PATCH 1/2] optional: add operator== and operator!= Message-ID: References: <20220314181312.3436802-1-gprocida@google.com> <20220314181312.3436802-2-gprocida@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220314181312.3436802-2-gprocida@google.com> X-Spam-Status: No, score=-29.7 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: Tue, 15 Mar 2022 11:02:50 -0000 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; >+ >+ 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". Cheers, Matthias > }; > > #endif >-- >2.35.1.723.g4982287a31-goog >