[gcc r15-283] libstdc++: Simplify std::variant comparison operators
Jonathan Wakely
redi@gcc.gnu.org
Tue May 7 13:45:19 GMT 2024
https://gcc.gnu.org/g:6709e35457a30b2184fa8337aa4abdd2c0edaeb3
commit r15-283-g6709e35457a30b2184fa8337aa4abdd2c0edaeb3
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Thu Mar 28 14:19:45 2024 +0000
libstdc++: Simplify std::variant comparison operators
libstdc++-v3/ChangeLog:
* include/std/variant (_VARIANT_RELATION_FUNCTION_TEMPLATE):
Simplify.
Diff:
---
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 8072e1f17a8..bf05eec9a6b 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
More information about the Libstdc++-cvs
mailing list