From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id E1F123857C4A for ; Thu, 17 Mar 2022 10:56:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E1F123857C4A Received: by mail-wm1-x329.google.com with SMTP id l1-20020a05600c4f0100b00389645443d2so2941665wmq.2 for ; Thu, 17 Mar 2022 03:56:17 -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=6W8DRO1SjjGxA1SO252WLk6/bA0ujyy/w7uI51U3EsA=; b=rh/poOYNfcwxw1jmU5rtEAINvP3e3uL/YfquYKs2IplEp2IDwfpChRHkqTn9H6TyNU ofGPwYy8Nr841yclhxLpNknUdn0+S8oc5MjlOsfonW5mH9zvMwnmThyWeeIT5RkcnAof i1ajUDJ2pX+O7n8lySUKn9PP/wDvLR/kF1/+D45xpeJozA/1R7oawLzqzcxf6FDbdgSG sQIutueJkH0Gl+ksnDXBpAwPTvw3MW7dalqF+lV8cndbYIFO5S6JYyh+yS4ewoGjtjSU 2ToBr5dCNI5lbEFRqsK2VDxY98i2jxKF2Au38VsoQ9CR40NwEEH4581jELkyykmLKpLE +xgQ== X-Gm-Message-State: AOAM530NVSliAPbmx+y5AsWDM7itw/Pzfi1mBRx3KuUbvDfgqWAmMN9z iq8l4/g90UxloGY1X2hHf9Av8g== X-Google-Smtp-Source: ABdhPJyYyvHmWuMQHdcn2VJkHeJDwh+CQi9ViblYpou2jct2eZEu866DmcR2IC2zwcg39WL5mVuurw== X-Received: by 2002:a05:600c:26c8:b0:389:a542:c20b with SMTP id 8-20020a05600c26c800b00389a542c20bmr11020517wmv.46.1647514576368; Thu, 17 Mar 2022 03:56:16 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:8b6c:955c:c308:5566]) by smtp.gmail.com with ESMTPSA id o6-20020a05600c4fc600b00389d7b820a3sm4857011wmq.28.2022.03.17.03.56.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 03:56:15 -0700 (PDT) Date: Thu, 17 Mar 2022 10:56:15 +0000 From: Matthias Maennich To: Giuliano Procida Cc: libabigail@sourceware.org, dodji@seketeli.org, kernel-team@android.com Subject: Re: [PATCH v2 1/4] optional: minor improvements Message-ID: References: <20220314181312.3436802-1-gprocida@google.com> <20220316163055.4127796-1-gprocida@google.com> <20220316163055.4127796-2-gprocida@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20220316163055.4127796-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: Thu, 17 Mar 2022 10:56:19 -0000 On Wed, Mar 16, 2022 at 04:30:52PM +0000, Giuliano Procida wrote: >This change makes minor improvements to the optional class used with >pre-C++17 compilers. > >- adds operator== and operator!= >- adds various missing noexcept (but not constexpr) decorations >- defines operator bool in terms of has_value > >Note that some constexpr decorations would require C++17 anyway. > > * include/abg-cxx-compat.h (optional): Add operator== and > operator!=. Add noexcept decorations. Tweak operator bool. > >Signed-off-by: Giuliano Procida Reviewed-by: Matthias Maennich Cheers, Matthias >--- > include/abg-cxx-compat.h | 30 ++++++++++++++++++++++++------ > 1 file changed, 24 insertions(+), 6 deletions(-) > >diff --git a/include/abg-cxx-compat.h b/include/abg-cxx-compat.h >index 443905c7..5c5943d0 100644 >--- a/include/abg-cxx-compat.h >+++ b/include/abg-cxx-compat.h >@@ -45,7 +45,7 @@ public: > optional(const T& value) : has_value_(true), value_(value) {} > > bool >- has_value() const >+ has_value() const noexcept > { > return has_value_; > } >@@ -67,19 +67,19 @@ public: > } > > const T& >- operator*() const >+ operator*() const& noexcept > { return value_; } > > T& >- operator*() >+ operator*() & noexcept > { return value_; } > > const T* >- operator->() const >+ operator->() const noexcept > { return &value_; } > > T* >- operator->() >+ operator->() noexcept > { return &value_; } > > optional& >@@ -90,9 +90,27 @@ public: > return *this; > } > >- explicit operator bool() const { return has_value_; } >+ explicit operator bool() const noexcept { return has_value(); } > }; > >+template >+bool >+operator==(const optional& lhs, const optional& rhs) >+{ >+ if (!lhs.has_value() && !rhs.has_value()) >+ return true; >+ if (!lhs.has_value() || !rhs.has_value()) >+ return false; >+ return lhs.value() == rhs.value(); >+} >+ >+template >+bool >+operator!=(const optional& lhs, const optional& rhs) >+{ >+ return !(lhs == rhs); >+} >+ > #endif > } > >-- >2.35.1.894.gb6a874cedc-goog >