This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Add test for algorithm result type alias declarations
ClosedPublic

Authored by philnik on Jul 6 2022, 4:30 AM.

Diff Detail

Event Timeline

philnik created this revision.Jul 6 2022, 4:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2022, 4:30 AM
philnik requested review of this revision.Jul 6 2022, 4:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 6 2022, 4:30 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
var-const requested changes to this revision.Jul 6 2022, 4:07 PM
var-const added inline comments.
libcxx/test/std/algorithms/ranges_result_alias_declarations.compile.pass.cpp
10

You probably need to add UNSUPPORTED.

19

Optional nit: any reason not to use same_as?

22

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>>);
This revision now requires changes to proceed.Jul 6 2022, 4:07 PM

Nit: s/algorihtm/algorithm/ in the name.

philnik retitled this revision from [libc++] Add test for algorihtm result type alias declarations to [libc++] Add test for algorithm result type alias declarations.Jul 6 2022, 4:13 PM
var-const added inline comments.Jul 6 2022, 4:14 PM
libcxx/test/std/algorithms/ranges_result_alias_declarations.compile.pass.cpp
22

Although to be fair, we do that already in the algorithm test files, so this would be duplicative.

philnik updated this revision to Diff 442712.Jul 6 2022, 4:20 PM
philnik marked 3 inline comments as done.
  • Address comments
libcxx/test/std/algorithms/ranges_result_alias_declarations.compile.pass.cpp
19

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).

22

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.

var-const accepted this revision.Jul 6 2022, 4:23 PM

Thanks!

This revision is now accepted and ready to land.Jul 6 2022, 4:23 PM