forked from OSchip/llvm-project
[libcxx] adds concept `std::move_constructible`
Implements parts of: - P0898R3 Standard Library Concepts - P1754 Rename concepts to standard_case for C++20, while we still can Depends on D77961 Differential Revision: https://reviews.llvm.org/D96230
This commit is contained in:
parent
564788ddce
commit
2b2f36a8b1
|
@ -184,6 +184,11 @@ template<class _Tp>
|
||||||
concept default_initializable = constructible_from<_Tp> &&
|
concept default_initializable = constructible_from<_Tp> &&
|
||||||
requires { _Tp{}; } && __default_initializable<_Tp>;
|
requires { _Tp{}; } && __default_initializable<_Tp>;
|
||||||
|
|
||||||
|
// [concept.moveconstructible]
|
||||||
|
template<class _Tp>
|
||||||
|
concept move_constructible =
|
||||||
|
constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
|
||||||
|
|
||||||
#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
|
#endif //_LIBCPP_STD_VER > 17 && defined(__cpp_concepts) && __cpp_concepts >= 201811L
|
||||||
|
|
||||||
_LIBCPP_END_NAMESPACE_STD
|
_LIBCPP_END_NAMESPACE_STD
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
|
||||||
|
// UNSUPPORTED: libcpp-no-concepts
|
||||||
|
|
||||||
|
// template<class T>
|
||||||
|
// concept move_constructible;
|
||||||
|
|
||||||
|
#include <concepts>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "moveconstructible.h"
|
||||||
|
|
||||||
|
static_assert(std::move_constructible<int>);
|
||||||
|
static_assert(std::move_constructible<int*>);
|
||||||
|
static_assert(std::move_constructible<int&>);
|
||||||
|
static_assert(std::move_constructible<int&&>);
|
||||||
|
static_assert(std::move_constructible<const int>);
|
||||||
|
static_assert(std::move_constructible<const int&>);
|
||||||
|
static_assert(std::move_constructible<const int&&>);
|
||||||
|
static_assert(std::move_constructible<volatile int>);
|
||||||
|
static_assert(std::move_constructible<volatile int&>);
|
||||||
|
static_assert(std::move_constructible<volatile int&&>);
|
||||||
|
static_assert(std::move_constructible<int (*)()>);
|
||||||
|
static_assert(std::move_constructible<int (&)()>);
|
||||||
|
static_assert(std::move_constructible<HasDefaultOps>);
|
||||||
|
static_assert(std::move_constructible<CustomMoveCtor>);
|
||||||
|
static_assert(std::move_constructible<MoveOnly>);
|
||||||
|
static_assert(std::move_constructible<const CustomMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<volatile CustomMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<const CustomMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<volatile CustomMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<CustomMoveAssign>);
|
||||||
|
static_assert(std::move_constructible<const CustomMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<volatile CustomMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<const CustomMoveAssign&&>);
|
||||||
|
static_assert(std::move_constructible<volatile CustomMoveAssign&&>);
|
||||||
|
static_assert(std::move_constructible<int HasDefaultOps::*>);
|
||||||
|
static_assert(std::move_constructible<void (HasDefaultOps::*)(int)>);
|
||||||
|
static_assert(std::move_constructible<MemberLvalueReference>);
|
||||||
|
static_assert(std::move_constructible<MemberRvalueReference>);
|
||||||
|
|
||||||
|
static_assert(!std::move_constructible<void>);
|
||||||
|
static_assert(!std::move_constructible<const CustomMoveCtor>);
|
||||||
|
static_assert(!std::move_constructible<volatile CustomMoveCtor>);
|
||||||
|
static_assert(!std::move_constructible<const CustomMoveAssign>);
|
||||||
|
static_assert(!std::move_constructible<volatile CustomMoveAssign>);
|
||||||
|
static_assert(!std::move_constructible<int[10]>);
|
||||||
|
static_assert(!std::move_constructible<DeletedMoveCtor>);
|
||||||
|
static_assert(!std::move_constructible<ImplicitlyDeletedMoveCtor>);
|
||||||
|
static_assert(!std::move_constructible<DeletedMoveAssign>);
|
||||||
|
static_assert(!std::move_constructible<ImplicitlyDeletedMoveAssign>);
|
||||||
|
|
||||||
|
static_assert(std::move_constructible<DeletedMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<DeletedMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<const DeletedMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<const DeletedMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<ImplicitlyDeletedMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<ImplicitlyDeletedMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<const ImplicitlyDeletedMoveCtor&>);
|
||||||
|
static_assert(std::move_constructible<const ImplicitlyDeletedMoveCtor&&>);
|
||||||
|
static_assert(std::move_constructible<DeletedMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<DeletedMoveAssign&&>);
|
||||||
|
static_assert(std::move_constructible<const DeletedMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<const DeletedMoveAssign&&>);
|
||||||
|
static_assert(std::move_constructible<ImplicitlyDeletedMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<ImplicitlyDeletedMoveAssign&&>);
|
||||||
|
static_assert(std::move_constructible<const ImplicitlyDeletedMoveAssign&>);
|
||||||
|
static_assert(std::move_constructible<const ImplicitlyDeletedMoveAssign&&>);
|
||||||
|
|
||||||
|
int main(int, char**) { return 0; }
|
|
@ -0,0 +1,61 @@
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
#ifndef TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
|
||||||
|
#define TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
|
||||||
|
|
||||||
|
struct HasDefaultOps {};
|
||||||
|
|
||||||
|
struct CustomMoveCtor {
|
||||||
|
CustomMoveCtor(CustomMoveCtor&&) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct MoveOnly {
|
||||||
|
MoveOnly(MoveOnly&&) noexcept = default;
|
||||||
|
MoveOnly& operator=(MoveOnly&&) noexcept = default;
|
||||||
|
MoveOnly(const MoveOnly&) = delete;
|
||||||
|
MoveOnly& operator=(const MoveOnly&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CustomMoveAssign {
|
||||||
|
CustomMoveAssign(CustomMoveAssign&&) noexcept;
|
||||||
|
CustomMoveAssign& operator=(CustomMoveAssign&&) noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DeletedMoveCtor {
|
||||||
|
DeletedMoveCtor(DeletedMoveCtor&&) = delete;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImplicitlyDeletedMoveCtor {
|
||||||
|
DeletedMoveCtor X;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DeletedMoveAssign {
|
||||||
|
DeletedMoveAssign& operator=(DeletedMoveAssign&&) = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ImplicitlyDeletedMoveAssign {
|
||||||
|
DeletedMoveAssign X;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MemberLvalueReference {
|
||||||
|
public:
|
||||||
|
MemberLvalueReference(int&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int& X;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MemberRvalueReference {
|
||||||
|
public:
|
||||||
|
MemberRvalueReference(int&&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int&& X;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
|
Loading…
Reference in New Issue