[libcxx-commits] [libcxx] [libc++] Optimize std::find if types are integral (PR #70345)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Dec 14 09:20:56 PST 2023
================
@@ -113,6 +113,272 @@ struct TestTypes {
}
};
+enum class match {
+ none,
+ first,
+};
+
+template <class T, class U>
+TEST_CONSTEXPR_CXX20 void test_integer_promotion(match min_expected, match max_expected) {
+ { // check min value
----------------
ldionne wrote:
Instead you could say:
```
bool should_match = T(value) == U(value);
```
and then it doesn't really matter what size different types are, you'd be checking that we have the same behavior that a "naive" implementation of `std::find` (using `==`) would have, which is really what we care about here.
https://github.com/llvm/llvm-project/pull/70345
More information about the libcxx-commits
mailing list