This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Use dedicated types for the invocable concept tests for multiple overloads
ClosedPublic

Authored by mstorsjo on Apr 6 2021, 12:24 AM.

Details

Summary

This should be clearer, instead of relying on rules for implicit
conversions regarding built in float/integer types.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Apr 6 2021, 12:24 AM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 6 2021, 12:24 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

I think that now we test less than before. Precisely, this code tested before that e.g. one could invoke f(double) with a float argument.
I'd like to see:

struct DA : A {};
struct DB : B {};

static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DA>);
static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DB>);

(and the same for std::invocable)

Apart from that, it looks good.

mstorsjo updated this revision to Diff 335434.Apr 6 2021, 1:54 AM

Updated to include tests that a derived type can be converted to a base type.

curdeius accepted this revision as: curdeius.Apr 6 2021, 2:18 AM

LGTM.

ldionne accepted this revision.Apr 6 2021, 9:01 AM
ldionne added a subscriber: ldionne.

That was the intent of my comment on the other review (and Arthur's original comment too) AFAICT. Thanks!

This revision is now accepted and ready to land.Apr 6 2021, 9:01 AM
This revision was landed with ongoing or failed builds.Apr 6 2021, 9:55 AM
This revision was automatically updated to reflect the committed changes.
libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
240

@curdeius wrote:

I think that now we test less than before. [...] I'd like to see:
struct DA : A {};

I had tested that codepath (that invocable deals correctly with implicit-conversions-to-the-parameter-type) by std::invocable<multiple_overloads, int> (int being implicitly convertible to B).
There's certainly no reason to test all DA and DB and int — all three are exactly isomorphic, user-defined implicit conversions via non-explicit constructor.

@curdeius, any objection if I re-remove DA and DB? (If so: Any objection if I remove DB and B(int)? If so: I'll remove DB.)

curdeius added inline comments.Apr 6 2021, 11:59 AM
libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
240

I agree that we don't need both DA and DB at the same time, the same way we don't need both A and B at the same time.
So, go on.