[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`
This commit is contained in:
Christopher Di Bella 2021-03-04 22:07:45 -08:00
parent 063b19dea6
commit 6eb5d55c55
6 changed files with 21 additions and 21 deletions

View File

@ -243,6 +243,14 @@ template<class _Tp>
concept move_constructible = concept move_constructible =
constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; 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] // [concept.booleantestable]
template<class _Tp> template<class _Tp>
concept __boolean_testable_impl = convertible_to<_Tp, bool>; concept __boolean_testable_impl = convertible_to<_Tp, bool>;
@ -275,14 +283,6 @@ concept equality_comparable_with =
const remove_reference_t<_Up>&>> && const remove_reference_t<_Up>&>> &&
__weakly_equality_comparable_with<_Tp, _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] // [concept.invocable]
template<class _Fn, class... _Args> template<class _Fn, class... _Args>
concept invocable = requires(_Fn&& __fn, _Args&&... __args) { concept invocable = requires(_Fn&& __fn, _Args&&... __args) {

View File

@ -49,7 +49,7 @@ int main(int, char**) {
NotInvocable(&A::F); NotInvocable(&A::F);
{ {
auto X = A{}; A X;
ModelsInvocable(&A::I, X); ModelsInvocable(&A::I, X);
ModelsInvocable(&A::F, X); ModelsInvocable(&A::F, X);
ModelsInvocable(&A::G, X, 0); ModelsInvocable(&A::G, X, 0);
@ -57,7 +57,7 @@ int main(int, char**) {
NotInvocable(&A::G, 0); NotInvocable(&A::G, 0);
NotInvocable(&A::H); NotInvocable(&A::H);
auto const& Y = X; A const& Y = X;
ModelsInvocable(&A::I, Y); ModelsInvocable(&A::I, Y);
ModelsInvocable(&A::F, Y); ModelsInvocable(&A::F, Y);
NotInvocable(&A::G, Y, 0); NotInvocable(&A::G, Y, 0);

View File

@ -48,7 +48,7 @@ int main(int, char**) {
NotRegularInvocable(&A::F); NotRegularInvocable(&A::F);
{ {
auto X = A{}; A X;
ModelsRegularInvocable(&A::I, X); ModelsRegularInvocable(&A::I, X);
ModelsRegularInvocable(&A::F, X); ModelsRegularInvocable(&A::F, X);
ModelsRegularInvocable(&A::G, X, 0); ModelsRegularInvocable(&A::G, X, 0);
@ -56,7 +56,7 @@ int main(int, char**) {
NotRegularInvocable(&A::G, 0); NotRegularInvocable(&A::G, 0);
NotRegularInvocable(&A::H); NotRegularInvocable(&A::H);
auto const& Y = X; A const& Y = X;
ModelsRegularInvocable(&A::I, Y); ModelsRegularInvocable(&A::I, Y);
ModelsRegularInvocable(&A::F, Y); ModelsRegularInvocable(&A::F, Y);
NotRegularInvocable(&A::G, Y, 0); NotRegularInvocable(&A::G, Y, 0);

View File

@ -125,14 +125,14 @@ struct cxx20_friend_eq_operator_with_deleted_ne {
struct member_three_way_comparable_with_deleted_eq { struct member_three_way_comparable_with_deleted_eq {
auto operator<=>(member_three_way_comparable_with_deleted_eq const&) const = auto operator<=>(member_three_way_comparable_with_deleted_eq const&) const =
default; default;
auto bool
operator==(member_three_way_comparable_with_deleted_eq const&) const = delete; operator==(member_three_way_comparable_with_deleted_eq const&) const = delete;
}; };
struct member_three_way_comparable_with_deleted_ne { struct member_three_way_comparable_with_deleted_ne {
auto operator<=>(member_three_way_comparable_with_deleted_ne const&) const = auto operator<=>(member_three_way_comparable_with_deleted_ne const&) const =
default; default;
auto bool
operator!=(member_three_way_comparable_with_deleted_ne const&) const = delete; 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 friend auto
operator<=>(friend_three_way_comparable_with_deleted_eq const&, operator<=>(friend_three_way_comparable_with_deleted_eq const&,
friend_three_way_comparable_with_deleted_eq const&) = default; friend_three_way_comparable_with_deleted_eq const&) = default;
friend auto friend bool
operator==(friend_three_way_comparable_with_deleted_eq const&, operator==(friend_three_way_comparable_with_deleted_eq const&,
friend_three_way_comparable_with_deleted_eq const&) = delete; friend_three_way_comparable_with_deleted_eq const&) = delete;
}; };
@ -149,7 +149,7 @@ struct friend_three_way_comparable_with_deleted_ne {
friend auto friend auto
operator<=>(friend_three_way_comparable_with_deleted_ne const&, operator<=>(friend_three_way_comparable_with_deleted_ne const&,
friend_three_way_comparable_with_deleted_ne const&) = default; friend_three_way_comparable_with_deleted_ne const&) = default;
friend auto friend bool
operator!=(friend_three_way_comparable_with_deleted_ne const&, operator!=(friend_three_way_comparable_with_deleted_ne const&,
friend_three_way_comparable_with_deleted_ne const&) = delete; friend_three_way_comparable_with_deleted_ne const&) = delete;
}; };

View File

@ -125,7 +125,7 @@ template <typename T1, typename T2>
constexpr bool CheckAssignableFromRvalues() { constexpr bool CheckAssignableFromRvalues() {
NeverAssignableFrom<T1, T2>(); 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); static_assert(std::assignable_from<T1&, T2&&> == Result);
return Result; return Result;
@ -135,7 +135,7 @@ template <typename T1, typename T2>
constexpr bool CheckAssignableFromLvalues() { constexpr bool CheckAssignableFromLvalues() {
NeverAssignableFrom<T1, T2>(); 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&, T2&> == Result);
static_assert(std::assignable_from<T1&, const T2&> == Result); static_assert(std::assignable_from<T1&, const T2&> == Result);
@ -543,8 +543,8 @@ static_assert(!CheckAssignableFromLvaluesAndRvalues<
static_assert(CheckAssignableFromLvaluesAndRvalues<std::vector<int>, static_assert(CheckAssignableFromLvaluesAndRvalues<std::vector<int>,
std::vector<int> >()); std::vector<int> >());
static_assert(!CheckAssignableFromLvaluesAndRvalues<std::vector<int>, static_assert(!CheckAssignableFromLvaluesAndRvalues<std::deque<int>,
std::vector<const int> >()); std::deque<const int> >());
static_assert(!CheckAssignableFromLvaluesAndRvalues< static_assert(!CheckAssignableFromLvaluesAndRvalues<
std::vector<int>, std::vector<int, A1<int> > >()); std::vector<int>, std::vector<int, A1<int> > >());
static_assert(!CheckAssignableFromLvaluesAndRvalues<std::vector<int>, static_assert(!CheckAssignableFromLvaluesAndRvalues<std::vector<int>,

View File

@ -16,7 +16,7 @@
template <class T, class U> template <class T, class U>
constexpr bool CheckCommonWith() noexcept { 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, U&> == result);
static_assert(std::common_with<T, const U&> == result); static_assert(std::common_with<T, const U&> == result);
static_assert(std::common_with<T, volatile U&> == result); static_assert(std::common_with<T, volatile U&> == result);