Message ID | 20220314181312.3436802-2-gprocida@google.com |
---|---|
State | New |
Headers |
Return-Path: <libabigail-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69C7E385841B for <patchwork@sourceware.org>; Mon, 14 Mar 2022 18:13:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69C7E385841B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1647281609; bh=wTqjIFDoDcDbJ4T03f70zsk0WcXCqU35dhEr6b4BaII=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=B8RkiBQirslr+2IMrkcCjFUqUszlYdM2ZhDYUgguiBsu9MKXh3QG+ctoQ0jyf/uPL Dr7Loat3W2L6m/hREraoegM8rK6WFU8dtmssK8550R9GhzV3GN7viQFZpPpgU6y5Lo GLfNxvKnYR3Ekcy0VTqyzl23wbL60wncqUeE6+iM= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by sourceware.org (Postfix) with ESMTPS id 4DEF93858D28 for <libabigail@sourceware.org>; Mon, 14 Mar 2022 18:13:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DEF93858D28 Received: by mail-ed1-x54a.google.com with SMTP id co2-20020a0564020c0200b00415f9fa6ca8so9254882edb.6 for <libabigail@sourceware.org>; Mon, 14 Mar 2022 11:13:24 -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:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wTqjIFDoDcDbJ4T03f70zsk0WcXCqU35dhEr6b4BaII=; b=761H/FaOoY9uON1xrLG7hNZWcgeUwdGAwn9Gr4TCtEFdC5Y8Lmq5oe2tHwhQ0nrQF3 TC1vV02dJ/qk7NlPygLYiWm8RJpLgwUN/emEEBZqKDZjkbVl9SkyR1xExRXZW9aQ+/PM bvOVdf128x8gn6ReyWtODU1sz98EUI+Qh5YxDPkg45dvVafYupmuBrFsWgo4YYwfVept oOqXhdJxBBgnoJQSd3FhBJcou6Fm5Ok+mzKdIUel8Q28NZ3QUxNYXNq07+QqwzbYoCQC esFVcK0XjDdfuboYSYk/qrjzQBap2XeW4jb8k/Oj2imsusx014V6xdcGVXTt8RZRkAnI JBgA== X-Gm-Message-State: AOAM532XoeuRcVWsP/Jbe0woE9kh2o4TeE3zU4WZcdgbwz3iUmlG9fdj oPSrYz4j3iBx9ou4ctNmZ8yce9MJCzHAsteG55Fiqn+jHwSAvFFmbKV25mw+FZUIPI5WW+jb+WC BLUpuqj2CzW4YZ1znOG3Vs8A1leaIAA9IGtO7KaVhlLRGDQn1MsiDEbIP9/0ikSn+zEIqAuE= X-Google-Smtp-Source: ABdhPJxFUah0Tt5omi0gHm3/Ud7lNCbdu8T9GzpPJwaDvnJ+VMbnJzlcuUMW3ARKXLzgzmNZ0B07x3lYxCPOhw== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:26a:3b8d:2ee5:1224]) (user=gprocida job=sendgmr) by 2002:a17:907:7b86:b0:6da:8a95:35bf with SMTP id ne6-20020a1709077b8600b006da8a9535bfmr19071275ejc.652.1647281602936; Mon, 14 Mar 2022 11:13:22 -0700 (PDT) Date: Mon, 14 Mar 2022 18:13:11 +0000 In-Reply-To: <20220314181312.3436802-1-gprocida@google.com> Message-Id: <20220314181312.3436802-2-gprocida@google.com> Mime-Version: 1.0 References: <20220314181312.3436802-1-gprocida@google.com> X-Mailer: git-send-email 2.35.1.723.g4982287a31-goog Subject: [PATCH 1/2] optional: add operator== and operator!= To: libabigail@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-21.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_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 <libabigail.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libabigail>, <mailto:libabigail-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libabigail/> List-Help: <mailto:libabigail-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libabigail>, <mailto:libabigail-request@sourceware.org?subject=subscribe> From: Giuliano Procida via Libabigail <libabigail@sourceware.org> Reply-To: Giuliano Procida <gprocida@google.com> Cc: maennich@google.com, kernel-team@android.com Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" <libabigail-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Bug 28954 - add Linux Kernel symbol namespace support
|
|
Commit Message
Giuliano Procida
March 14, 2022, 6:13 p.m. UTC
* include/abg-cxx-compat.h (optional): Add operator== and
operator!=.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
include/abg-cxx-compat.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
Comments
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 <gprocida@google.com> >--- > 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<T>& 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<T>& 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 >
Hi. On Tue, 15 Mar 2022 at 11:02, Matthias Maennich <maennich@google.com> 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 <gprocida@google.com> > >--- > > 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<T>& 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<T>& 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 > >
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_; } + + bool + operator==(const optional<T>& 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<T>& other) const + { + return !operator==(other); + } }; #endif