[libcxx-commits] [PATCH] D131395: [libc++] Implement `lexicographical_compare_three_way`
Adrian Vogelsgesang via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 15 16:16:34 PDT 2022
avogelsgesang added inline comments.
================
Comment at: libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way.pass.cpp:41-43
+ auto result =
+ std::lexicographical_compare_three_way(Iter1{a.begin()}, Iter1{a.end()}, Iter2{b.begin()}, Iter2{b.end()});
+ ASSERT_SAME_TYPE(decltype(result), Order);
----------------
huixie90 wrote:
> optional: In other C++20 algorithm tests, we usually do
> ```
> std::same_as<ExpectedType> result = std::foo_bar_algorithm(...);
> ```
> But feel free to ignore this.
Nice technique! I didn't know this application of `same_as` yet
================
Comment at: libcxx/test/std/algorithms/alg.sorting/alg.three.way/lexicographical_compare_three_way.pass.cpp:44
+ ASSERT_SAME_TYPE(decltype(result), Order);
+ return expected == result;
+}
----------------
huixie90 wrote:
> extra nit: In other tests, we usually just `assert(expected == result)` here to save writing all the `assert`s on the caller site.
I modelled this helper function here after the `test*` functions from `test_comparisons.h`. Do you want me to also update the helper functions from `test_comparisons.h` (in a separate commit), deviate from the pattern from `test_comparisons.h` here, or keep everything as currently proposed in this review?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131395/new/
https://reviews.llvm.org/D131395
More information about the libcxx-commits
mailing list