public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Matthias Maennich <maennich@google.com>
To: Giuliano Procida <gprocida@google.com>
Cc: libabigail@sourceware.org, dodji@seketeli.org, kernel-team@android.com
Subject: Re: [PATCH v2 1/4] optional: minor improvements
Date: Thu, 17 Mar 2022 10:56:15 +0000	[thread overview]
Message-ID: <YjMTz/xHHXQ02eps@google.com> (raw)
In-Reply-To: <20220316163055.4127796-2-gprocida@google.com>

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 <gprocida@google.com>

Reviewed-by: Matthias Maennich <maennich@google.com>

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 <typename T, typename U>
>+bool
>+operator==(const optional<T>& lhs, const optional<U>& 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 <typename T, typename U>
>+bool
>+operator!=(const optional<T>& lhs, const optional<U>& rhs)
>+{
>+  return !(lhs == rhs);
>+}
>+
> #endif
> }
>
>-- 
>2.35.1.894.gb6a874cedc-goog
>

  reply	other threads:[~2022-03-17 10:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 18:13 [PATCH 0/2] Bug 28954 - add Linux Kernel symbol namespace support Giuliano Procida
2022-03-14 18:13 ` [PATCH 1/2] optional: add operator== and operator!= Giuliano Procida
2022-03-15 11:02   ` Matthias Maennich
2022-03-16  9:31     ` Giuliano Procida
2022-03-14 18:13 ` [PATCH 2/2] add Linux kernel symbol namespace support Giuliano Procida
2022-03-15 11:25   ` Matthias Maennich
2022-03-16 16:30 ` [PATCH v2 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-16 16:30   ` [PATCH v2 1/4] optional: minor improvements Giuliano Procida
2022-03-17 10:56     ` Matthias Maennich [this message]
2022-03-16 16:30   ` [PATCH v2 2/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-03-17 11:01     ` Matthias Maennich
2022-03-16 16:30   ` [PATCH v2 3/4] add Linux kernel symbol namespace support Giuliano Procida
2022-03-17 11:57     ` Matthias Maennich
2022-03-16 16:30   ` [PATCH v2 4/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-17 12:01     ` Matthias Maennich
2022-03-17 16:38   ` [PATCH v3 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 2/4] optional: minor improvements Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-17 16:38     ` [PATCH v3 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-03-21 12:53       ` Matthias Maennich
2022-03-21 15:52         ` Giuliano Procida
2022-03-21 16:02     ` [PATCH v4 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 2/4] optional: minor improvements Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-03-21 16:02       ` [PATCH v4 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-06-13 14:25       ` [PATCH v5 0/4] add symbol namespace support, update symbol CRC support Giuliano Procida
2022-06-30 16:39         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 1/4] crc_changed: eliminate copying of shared_ptr values Giuliano Procida
2022-06-30 16:40         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 2/4] optional: minor improvements Giuliano Procida
2022-06-30 16:40         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 3/4] Linux symbol CRCs: support 0 and report presence changes Giuliano Procida
2022-06-30 16:41         ` Dodji Seketeli
2022-06-13 14:25       ` [PATCH v5 4/4] add Linux kernel symbol namespace support Giuliano Procida
2022-07-01 12:54         ` Dodji Seketeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YjMTz/xHHXQ02eps@google.com \
    --to=maennich@google.com \
    --cc=dodji@seketeli.org \
    --cc=gprocida@google.com \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).