From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH 4/4] libstdc++: Simplify std::variant comparison operators
Date: Wed, 10 Apr 2024 09:45:56 +0100 [thread overview]
Message-ID: <20240410085039.267589-4-jwakely@redhat.com> (raw)
In-Reply-To: <20240410085039.267589-1-jwakely@redhat.com>
Tested x86_64-linux.
This is just a minor clean-up and could wait for stage 1.
-- >8 --
libstdc++-v3/ChangeLog:
* include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE):
Simplify.
---
libstdc++-v3/include/std/variant | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 5ba6d9d42e3..2be0f0c1db7 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1245,7 +1245,7 @@ namespace __variant
# define _VARIANT_RELATION_FUNCTION_CONSTRAINTS(TYPES, OP)
#endif
-#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP, __NAME) \
+#define _VARIANT_RELATION_FUNCTION_TEMPLATE(__OP) \
template<typename... _Types> \
_VARIANT_RELATION_FUNCTION_CONSTRAINTS(_Types, __OP) \
constexpr bool \
@@ -1262,22 +1262,20 @@ namespace __variant
{ \
auto& __this_mem = std::get<__rhs_index>(__lhs); \
__ret = __this_mem __OP __rhs_mem; \
+ return; \
} \
- else \
- __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \
} \
- else \
- __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \
+ __ret = (__lhs.index() + 1) __OP (__rhs_index + 1); \
}, __rhs); \
return __ret; \
}
- _VARIANT_RELATION_FUNCTION_TEMPLATE(<, less)
- _VARIANT_RELATION_FUNCTION_TEMPLATE(<=, less_equal)
- _VARIANT_RELATION_FUNCTION_TEMPLATE(==, equal)
- _VARIANT_RELATION_FUNCTION_TEMPLATE(!=, not_equal)
- _VARIANT_RELATION_FUNCTION_TEMPLATE(>=, greater_equal)
- _VARIANT_RELATION_FUNCTION_TEMPLATE(>, greater)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(<)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(<=)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(==)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(!=)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(>=)
+ _VARIANT_RELATION_FUNCTION_TEMPLATE(>)
#undef _VARIANT_RELATION_FUNCTION_TEMPLATE
--
2.44.0
next prev parent reply other threads:[~2024-04-10 8:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 8:45 [PATCH 1/4] libstdc++: Heterogeneous std::pair comparisons [PR113386] Jonathan Wakely
2024-04-10 8:45 ` [PATCH 2/4] libstdc++: Add std::reference_wrapper comparison operators for C++26 Jonathan Wakely
2024-04-15 18:30 ` Jonathan Wakely
2024-04-10 8:45 ` [PATCH 3/4] libstdc++: Constrain equality ops for std::pair, std::tuple, std::variant Jonathan Wakely
2024-04-10 8:45 ` Jonathan Wakely [this message]
2024-04-10 10:45 ` [PATCH 5/4] libstdc++: Rewrite std::variant comparisons without macros Jonathan Wakely
2024-05-07 13:45 ` [PATCH 4/4] libstdc++: Simplify std::variant comparison operators Jonathan Wakely
2024-04-15 18:29 ` [PATCH 1/4] libstdc++: Heterogeneous std::pair comparisons [PR113386] Jonathan Wakely
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=20240410085039.267589-4-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.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).