Skip to content

Commit

Permalink
[libcxx] fixes up some [concepts]-related code
Browse files Browse the repository at this point in the history
* moves `std::copy_constructible` so it comes before
  `std::equality_comparable_with`
* replaces a few uses of `auto`
  • Loading branch information
cjdb committed Mar 5, 2021
1 parent 063b19d commit 6eb5d55
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions libcxx/include/concepts
Expand Up @@ -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>;
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions libcxx/test/std/concepts/callable/invocable.compile.pass.cpp
Expand Up @@ -49,15 +49,15 @@ 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);
NotInvocable(&A::G, X);
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);
Expand Down
Expand Up @@ -48,15 +48,15 @@ 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);
NotRegularInvocable(&A::G, X);
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);
Expand Down
8 changes: 4 additions & 4 deletions libcxx/test/std/concepts/comparison/types.h
Expand Up @@ -125,22 +125,22 @@ 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;
};

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;
};
Expand All @@ -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;
};
Expand Down
8 changes: 4 additions & 4 deletions libcxx/test/std/concepts/lang/assignable.compile.pass.cpp
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/std/concepts/lang/common.compile.pass.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 6eb5d55

Please sign in to comment.