[libcxx-commits] [PATCH] D129189: [libc++] Add test for algorithm result type alias declarations
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 6 16:20:03 PDT 2022
philnik added inline comments.
================
Comment at: libcxx/test/std/algorithms/ranges_result_alias_declarations.compile.pass.cpp:18
+
+static_assert(std::is_same_v<in_fun_result<int, long>, for_each_result<int, long>>);
+static_assert(std::is_same_v<in_fun_result<int, long>, for_each_n_result<int, long>>);
----------------
var-const wrote:
> Optional nit: any reason not to use `same_as`?
`is_same` reads more naturally to me, but I think nothing about either of them is objectively better than the other one. Using `same_as` might be marginally more expensive for the compiler, but who knows (or cares).
================
Comment at: libcxx/test/std/algorithms/ranges_result_alias_declarations.compile.pass.cpp:21
+
+static_assert(std::is_same_v<in_in_result<int, long>, mismatch_result<int, long>>);
+static_assert(std::is_same_v<in_in_result<int, long>, swap_ranges_result<int, long>>);
----------------
var-const wrote:
> var-const wrote:
> > Do we also need to test that the corresponding algorithm returns the right type?
> > ```
> > static_assert(std::is_same_v<in_in_result<int, long>, mismatch_result<int, long>>);
> > static_assert(std::is_same_v<decltype(std::ranges::mismatch(i1, s1, i2, s2)), in_in_result<int, long>>);
> > ```
> Although to be fair, we do that already in the algorithm test files, so this would be duplicative.
Exactly. This test only exists to ensure that the aliases exist. There are probably a few tests where we don't actually check that, since `is_in_result<int, long>` and `swap_ranges_result<int, long>` are indistinguishable from each other.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129189/new/
https://reviews.llvm.org/D129189
More information about the libcxx-commits
mailing list