[compiler-rt] [libcxx] Unifying __is_trivial_equality_predicate and __is_trivial_plus_operation into __desugars_to (PR #68642)
Louis Dionne via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 30 08:40:00 PDT 2023
================
@@ -29,12 +30,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <
- typename _DifferenceType,
- typename _Tp,
- typename _BinaryOperation,
- typename _UnaryOperation,
- __enable_if_t<__is_trivial_plus_operation<_BinaryOperation, _Tp, _Tp>::value && is_arithmetic_v<_Tp>, int> = 0>
+template < typename _DifferenceType,
+ typename _Tp,
+ typename _BinaryOperation,
+ typename _UnaryOperation,
+ __enable_if_t<__desugars_to<_BinaryOperation, plus<_Tp> >::value && is_arithmetic_v<_Tp>, int> = 0>
----------------
ldionne wrote:
With the changes below, this comment would become:
```
template < typename _DifferenceType,
typename _Tp,
typename _BinaryOperation,
typename _UnaryOperation,
typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>,
__enable_if_t<__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value && is_arithmetic_v<_Tp>, int> = 0>
```
Also worth thinking whether we really need/want to restrict this to arithmetic types, since I could definitely imagine doing a reduction over e.g. strings. String concatenation is not commutative, but it is associative. Should this work?
https://github.com/llvm/llvm-project/pull/68642
More information about the llvm-commits
mailing list