[libcxx-commits] [libcxx] 31191e1 - [libc++] Fix concepts tests with GCC
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 26 08:22:11 PDT 2021
Author: Louis Dionne
Date: 2021-05-26T11:21:55-04:00
New Revision: 31191e15b6e362bcbd83353344bbb102f822762d
URL: https://github.com/llvm/llvm-project/commit/31191e15b6e362bcbd83353344bbb102f822762d
DIFF: https://github.com/llvm/llvm-project/commit/31191e15b6e362bcbd83353344bbb102f822762d.diff
LOG: [libc++] Fix concepts tests with GCC
Added:
libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp
Modified:
libcxx/test/std/concepts/concepts.callable/concept.invocable/invocable.compile.pass.cpp
Removed:
libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
################################################################################
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 ffad6d6d41b3b..ddded61520b9c 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
@@ -399,30 +399,17 @@ static_assert(std::invocable<rvalue_cv_unqualified, S const volatile&&>);
} // namespace pointer_to_member_functions
// std::invocable-specific
-static_assert(
- std::invocable<std::uniform_int_distribution<>, std::mt19937_64&>);
-
-[[nodiscard]] constexpr bool check_lambda(auto, auto...) { return false; }
+static_assert(std::invocable<std::uniform_int_distribution<>, std::mt19937_64&>);
-// clang-format off
+// Check the concept with closure types
template<class F, class... Args>
-requires std::invocable<F, Args...>
-[[nodiscard]] constexpr bool check_lambda(F, Args&&...)
-{
- return true;
-}
-// clang-format on
-
-[[nodiscard]] constexpr bool check_lambdas() {
- static_assert(check_lambda([] {}));
- static_assert(check_lambda([](int) {}, 0));
- static_assert(check_lambda([](int) {}, 0L));
- static_assert(!check_lambda([](int) {}, nullptr));
-
- int i = 0;
- return check_lambda([](int&) {}, i);
+constexpr bool is_invocable(F, Args&&...) {
+ return std::invocable<F, Args...>;
}
-static_assert(check_lambdas());
-
-int main(int, char**) { return 0; }
+static_assert(is_invocable([] {}));
+static_assert(is_invocable([](int) {}, 0));
+static_assert(is_invocable([](int) {}, 0L));
+static_assert(!is_invocable([](int) {}, nullptr));
+int i = 0;
+static_assert(is_invocable([](int&) {}, i));
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.compile.pass.cpp
similarity index 97%
rename from libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.pass.cpp
rename to libcxx/test/std/concepts/concepts.callable/concept.regularinvocable/regular_invocable.compile.pass.cpp
index 0e0570f1c14ae..7868def3cfe5d 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.compile.pass.cpp
@@ -436,34 +436,28 @@ static_assert(
std::regular_invocable<rvalue_cv_unqualified, S const volatile&&>);
} // namespace pointer_to_member_functions
-[[nodiscard]] constexpr bool check_lambda(auto, auto...) { return false; }
+// Check the concept with closure types (and also check for subsumption)
+template<class F, class... Args>
+constexpr bool is_regular_invocable(F, Args&&...) {
+ return false;
+}
-// clang-format off
template<class F, class... Args>
requires std::invocable<F, Args...>
-[[nodiscard]] constexpr bool check_lambda(F, Args&&...)
-{
+constexpr bool is_regular_invocable(F, Args&&...) {
return false;
}
template<class F, class... Args>
requires std::regular_invocable<F, Args...> && true
-[[nodiscard]] constexpr bool check_lambda(F, Args&&...)
-{
+constexpr bool is_regular_invocable(F, Args&&...) {
return true;
}
-// clang-format on
-
-[[nodiscard]] constexpr bool check_lambdas() {
- static_assert(check_lambda([] {}));
- static_assert(check_lambda([](int) {}, 0));
- static_assert(check_lambda([](int) {}, 0L));
- static_assert(!check_lambda([](int) {}, nullptr));
-
- int i = 0;
- return check_lambda([](int&) {}, i);
-}
-static_assert(check_lambdas());
+static_assert(is_regular_invocable([] {}));
+static_assert(is_regular_invocable([](int) {}, 0));
+static_assert(is_regular_invocable([](int) {}, 0L));
+static_assert(!is_regular_invocable([](int) {}, nullptr));
-int main(int, char**) { return 0; }
+int i = 0;
+static_assert(is_regular_invocable([](int&) {}, i));
More information about the libcxx-commits
mailing list