[libcxx-commits] [libcxx] 91d6deb - [libcxx] [test] Use dedicated types for the invocable concept tests for multiple overloads
Martin Storsjö via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 6 09:54:51 PDT 2021
Author: Martin Storsjö
Date: 2021-04-06T19:54:34+03:00
New Revision: 91d6debbb9136a0ac30278135bd4089c9e614ad1
URL: https://github.com/llvm/llvm-project/commit/91d6debbb9136a0ac30278135bd4089c9e614ad1
DIFF: https://github.com/llvm/llvm-project/commit/91d6debbb9136a0ac30278135bd4089c9e614ad1.diff
LOG: [libcxx] [test] Use dedicated types for the invocable concept tests for multiple overloads
This should be clearer, instead of relying on rules for implicit
conversions regarding built in float/integer types.
Differential Revision: https://reviews.llvm.org/D99928
Added:
Modified:
libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
index b485607626d55..5b15f156427c4 100644
--- a/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
@@ -222,21 +222,30 @@ static_assert(!std::invocable<rvalue_cv_function_object volatile&, int*>);
static_assert(!std::invocable<rvalue_cv_function_object const volatile&, int*>);
struct multiple_overloads {
- bool operator()();
- void operator()(int);
- int operator()(double);
+ struct A {};
+ struct B { B(int); };
+ struct AB : A, B {};
+ struct O {};
+ struct DA : A {};
+ struct DB : B {};
+ void operator()(A) {};
+ void operator()(B) {};
};
-static_assert(std::invocable<multiple_overloads&>);
-static_assert(std::invocable<multiple_overloads&, short>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::A>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::B>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::DA>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::DB>);
static_assert(std::invocable<multiple_overloads&, int>);
-static_assert(!std::invocable<multiple_overloads&, long long>);
-static_assert(std::invocable<multiple_overloads&, double>);
-static_assert(std::invocable<multiple_overloads&, float>);
-static_assert(std::invocable<multiple_overloads&, short&>);
+static_assert(!std::invocable<multiple_overloads&, multiple_overloads::AB>);
+static_assert(!std::invocable<multiple_overloads&, multiple_overloads::O>);
+
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::A&>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::B&>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::DA&>);
+static_assert(std::invocable<multiple_overloads&, multiple_overloads::DB&>);
static_assert(std::invocable<multiple_overloads&, int&>);
-static_assert(!std::invocable<multiple_overloads&, long long>);
-static_assert(std::invocable<multiple_overloads&, float&>);
-static_assert(std::invocable<multiple_overloads&, double&>);
+static_assert(!std::invocable<multiple_overloads&, multiple_overloads::AB&>);
+static_assert(!std::invocable<multiple_overloads&, multiple_overloads::O&>);
} // namespace function_objects
namespace pointer_to_member_functions {
diff --git a/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp b/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
index 4536dcc6c3d2f..49111858caa87 100644
--- a/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
@@ -248,21 +248,30 @@ static_assert(
!std::regular_invocable<rvalue_cv_function_object const volatile&, int*>);
struct multiple_overloads {
- bool operator()();
- void operator()(int);
- int operator()(double);
+ struct A {};
+ struct B { B(int); };
+ struct AB : A, B {};
+ struct O {};
+ struct DA : A {};
+ struct DB : B {};
+ void operator()(A) {};
+ void operator()(B) {};
};
-static_assert(std::regular_invocable<multiple_overloads&>);
-static_assert(std::regular_invocable<multiple_overloads&, short>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::A>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::B>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DA>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DB>);
static_assert(std::regular_invocable<multiple_overloads&, int>);
-static_assert(!std::regular_invocable<multiple_overloads&, long long>);
-static_assert(std::regular_invocable<multiple_overloads&, double>);
-static_assert(std::regular_invocable<multiple_overloads&, float>);
-static_assert(std::regular_invocable<multiple_overloads&, short&>);
+static_assert(!std::regular_invocable<multiple_overloads&, multiple_overloads::AB>);
+static_assert(!std::regular_invocable<multiple_overloads&, multiple_overloads::O>);
+
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::A&>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::B&>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DA&>);
+static_assert(std::regular_invocable<multiple_overloads&, multiple_overloads::DB&>);
static_assert(std::regular_invocable<multiple_overloads&, int&>);
-static_assert(!std::regular_invocable<multiple_overloads&, long long&>);
-static_assert(std::regular_invocable<multiple_overloads&, float&>);
-static_assert(std::regular_invocable<multiple_overloads&, double&>);
+static_assert(!std::regular_invocable<multiple_overloads&, multiple_overloads::AB&>);
+static_assert(!std::regular_invocable<multiple_overloads&, multiple_overloads::O&>);
} // namespace function_objects
namespace pointer_to_member_functions {
More information about the libcxx-commits
mailing list