[libcxx-commits] [libcxx] 6eb5d55 - [libcxx] fixes up some [concepts]-related code
Christopher Di Bella via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 4 22:10:19 PST 2021
Author: Christopher Di Bella
Date: 2021-03-04T22:09:43-08:00
New Revision: 6eb5d55c55d176f9baf0c50d915ec4ec798c413b
URL: https://github.com/llvm/llvm-project/commit/6eb5d55c55d176f9baf0c50d915ec4ec798c413b
DIFF: https://github.com/llvm/llvm-project/commit/6eb5d55c55d176f9baf0c50d915ec4ec798c413b.diff
LOG: [libcxx] fixes up some [concepts]-related code
* moves `std::copy_constructible` so it comes before
`std::equality_comparable_with`
* replaces a few uses of `auto`
Added:
Modified:
libcxx/include/concepts
libcxx/test/std/concepts/callable/invocable.compile.pass.cpp
libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp
libcxx/test/std/concepts/comparison/types.h
libcxx/test/std/concepts/lang/assignable.compile.pass.cpp
libcxx/test/std/concepts/lang/common.compile.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/concepts b/libcxx/include/concepts
index 88a18e96bf85..385ce098e1d3 100644
--- a/libcxx/include/concepts
+++ b/libcxx/include/concepts
@@ -243,6 +243,14 @@ template<class _Tp>
concept move_constructible =
constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
+// [concept.copyconstructible]
+template<class _Tp>
+concept copy_constructible =
+ move_constructible<_Tp> &&
+ constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
+ constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
+ constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
+
// [concept.booleantestable]
template<class _Tp>
concept __boolean_testable_impl = convertible_to<_Tp, bool>;
@@ -275,14 +283,6 @@ concept equality_comparable_with =
const remove_reference_t<_Up>&>> &&
__weakly_equality_comparable_with<_Tp, _Up>;
-// [concept.copyconstructible]
-template<class _Tp>
-concept copy_constructible =
- move_constructible<_Tp> &&
- constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
- constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
- constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
-
// [concept.invocable]
template<class _Fn, class... _Args>
concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
diff --git a/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp b/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp
index 9afa9d9a7126..cd415d8d0998 100644
--- a/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/callable/invocable.compile.pass.cpp
@@ -49,7 +49,7 @@ int main(int, char**) {
NotInvocable(&A::F);
{
- auto X = A{};
+ A X;
ModelsInvocable(&A::I, X);
ModelsInvocable(&A::F, X);
ModelsInvocable(&A::G, X, 0);
@@ -57,7 +57,7 @@ int main(int, char**) {
NotInvocable(&A::G, 0);
NotInvocable(&A::H);
- auto const& Y = X;
+ A const& Y = X;
ModelsInvocable(&A::I, Y);
ModelsInvocable(&A::F, Y);
NotInvocable(&A::G, Y, 0);
diff --git a/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp b/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp
index f342ca58af26..b085b7e50022 100644
--- a/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/callable/regularinvocable.compile.pass.cpp
@@ -48,7 +48,7 @@ int main(int, char**) {
NotRegularInvocable(&A::F);
{
- auto X = A{};
+ A X;
ModelsRegularInvocable(&A::I, X);
ModelsRegularInvocable(&A::F, X);
ModelsRegularInvocable(&A::G, X, 0);
@@ -56,7 +56,7 @@ int main(int, char**) {
NotRegularInvocable(&A::G, 0);
NotRegularInvocable(&A::H);
- auto const& Y = X;
+ A const& Y = X;
ModelsRegularInvocable(&A::I, Y);
ModelsRegularInvocable(&A::F, Y);
NotRegularInvocable(&A::G, Y, 0);
diff --git a/libcxx/test/std/concepts/comparison/types.h b/libcxx/test/std/concepts/comparison/types.h
index 281305324979..6f7689e22c61 100644
--- a/libcxx/test/std/concepts/comparison/types.h
+++ b/libcxx/test/std/concepts/comparison/types.h
@@ -125,14 +125,14 @@ struct cxx20_friend_eq_operator_with_deleted_ne {
struct member_three_way_comparable_with_deleted_eq {
auto operator<=>(member_three_way_comparable_with_deleted_eq const&) const =
default;
- auto
+ bool
operator==(member_three_way_comparable_with_deleted_eq const&) const = delete;
};
struct member_three_way_comparable_with_deleted_ne {
auto operator<=>(member_three_way_comparable_with_deleted_ne const&) const =
default;
- auto
+ bool
operator!=(member_three_way_comparable_with_deleted_ne const&) const = delete;
};
@@ -140,7 +140,7 @@ struct friend_three_way_comparable_with_deleted_eq {
friend auto
operator<=>(friend_three_way_comparable_with_deleted_eq const&,
friend_three_way_comparable_with_deleted_eq const&) = default;
- friend auto
+ friend bool
operator==(friend_three_way_comparable_with_deleted_eq const&,
friend_three_way_comparable_with_deleted_eq const&) = delete;
};
@@ -149,7 +149,7 @@ struct friend_three_way_comparable_with_deleted_ne {
friend auto
operator<=>(friend_three_way_comparable_with_deleted_ne const&,
friend_three_way_comparable_with_deleted_ne const&) = default;
- friend auto
+ friend bool
operator!=(friend_three_way_comparable_with_deleted_ne const&,
friend_three_way_comparable_with_deleted_ne const&) = delete;
};
diff --git a/libcxx/test/std/concepts/lang/assignable.compile.pass.cpp b/libcxx/test/std/concepts/lang/assignable.compile.pass.cpp
index 450c0bc56c7f..1278f84c10b5 100644
--- a/libcxx/test/std/concepts/lang/assignable.compile.pass.cpp
+++ b/libcxx/test/std/concepts/lang/assignable.compile.pass.cpp
@@ -125,7 +125,7 @@ template <typename T1, typename T2>
constexpr bool CheckAssignableFromRvalues() {
NeverAssignableFrom<T1, T2>();
- constexpr auto Result = std::assignable_from<T1&, T2>;
+ constexpr bool Result = std::assignable_from<T1&, T2>;
static_assert(std::assignable_from<T1&, T2&&> == Result);
return Result;
@@ -135,7 +135,7 @@ template <typename T1, typename T2>
constexpr bool CheckAssignableFromLvalues() {
NeverAssignableFrom<T1, T2>();
- constexpr auto Result = std::assignable_from<T1&, const T2&>;
+ constexpr bool Result = std::assignable_from<T1&, const T2&>;
static_assert(std::assignable_from<T1&, T2&> == Result);
static_assert(std::assignable_from<T1&, const T2&> == Result);
@@ -543,8 +543,8 @@ static_assert(!CheckAssignableFromLvaluesAndRvalues<
static_assert(CheckAssignableFromLvaluesAndRvalues<std::vector<int>,
std::vector<int> >());
-static_assert(!CheckAssignableFromLvaluesAndRvalues<std::vector<int>,
- std::vector<const int> >());
+static_assert(!CheckAssignableFromLvaluesAndRvalues<std::deque<int>,
+ std::deque<const int> >());
static_assert(!CheckAssignableFromLvaluesAndRvalues<
std::vector<int>, std::vector<int, A1<int> > >());
static_assert(!CheckAssignableFromLvaluesAndRvalues<std::vector<int>,
diff --git a/libcxx/test/std/concepts/lang/common.compile.pass.cpp b/libcxx/test/std/concepts/lang/common.compile.pass.cpp
index 6db6b5758024..d66d00d37080 100644
--- a/libcxx/test/std/concepts/lang/common.compile.pass.cpp
+++ b/libcxx/test/std/concepts/lang/common.compile.pass.cpp
@@ -16,7 +16,7 @@
template <class T, class U>
constexpr bool CheckCommonWith() noexcept {
- constexpr auto result = std::common_with<T, U>;
+ constexpr bool result = std::common_with<T, U>;
static_assert(std::common_with<T, U&> == result);
static_assert(std::common_with<T, const U&> == result);
static_assert(std::common_with<T, volatile U&> == result);
More information about the libcxx-commits
mailing list