const remove_reference_t<_Up>&>> &&
__weakly_equality_comparable_with<_Tp, _Up>;
+// [concepts.object]
+template<class _Tp>
+concept movable =
+ is_object_v<_Tp> &&
+ move_constructible<_Tp> &&
+ assignable_from<_Tp&, _Tp> &&
+ swappable<_Tp>;
+
// [concept.invocable]
template<class _Fn, class... _Args>
concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
#include <concepts>
#include <type_traits>
-#include "moveconstructible.h"
+#include "type_classification/moveconstructible.h"
// Tests in this namespace are shared with moveconstructible.pass.cpp
// There are some interesting differences, so it's best if they're tested here
#include <concepts>
#include <type_traits>
-#include "moveconstructible.h"
+#include "type_classification/moveconstructible.h"
static_assert(std::move_constructible<int>);
static_assert(std::move_constructible<int*>);
static_assert(std::move_constructible<const ImplicitlyDeletedMoveAssign&>);
static_assert(std::move_constructible<const ImplicitlyDeletedMoveAssign&&>);
+static_assert(!std::move_constructible<NonMovable>);
+static_assert(!std::move_constructible<DerivedFromNonMovable>);
+static_assert(!std::move_constructible<HasANonMovable>);
+
int main(int, char**) { return 0; }
#include <vector>
#include "test_macros.h"
-#include "moveconstructible.h"
-#include "swappable.h"
+#include "type_classification/moveconstructible.h"
+#include "type_classification/swappable.h"
template <class T>
struct expected {
#include <unordered_set>
#include <vector>
-#include "moveconstructible.h"
-#include "swappable.h"
+#include "type_classification/moveconstructible.h"
+#include "type_classification/swappable.h"
template <class T, class U>
constexpr bool check_swappable_with_impl() {
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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++03, c++11, c++14, c++17
+// UNSUPPORTED: libcpp-no-concepts
+
+// template<class T>
+// concept movable = see below;
+
+#include <concepts>
+
+#include <deque>
+#include <forward_list>
+#include <list>
+#include <map>
+#include <mutex>
+#include <optional>
+#include <unordered_map>
+#include <vector>
+
+#include "type_classification/moveconstructible.h"
+#include "type_classification/movable.h"
+
+// Movable types
+static_assert(std::movable<int>);
+static_assert(std::movable<int volatile>);
+static_assert(std::movable<int*>);
+static_assert(std::movable<int const*>);
+static_assert(std::movable<int volatile*>);
+static_assert(std::movable<int const volatile*>);
+static_assert(std::movable<int (*)()>);
+
+struct S {};
+static_assert(std::movable<S>);
+static_assert(std::movable<int S::*>);
+static_assert(std::movable<int (S::*)()>);
+static_assert(std::movable<int (S::*)() noexcept>);
+static_assert(std::movable<int (S::*)() &>);
+static_assert(std::movable<int (S::*)() & noexcept>);
+static_assert(std::movable<int (S::*)() &&>);
+static_assert(std::movable<int (S::*)() && noexcept>);
+static_assert(std::movable<int (S::*)() const>);
+static_assert(std::movable<int (S::*)() const noexcept>);
+static_assert(std::movable<int (S::*)() const&>);
+static_assert(std::movable<int (S::*)() const & noexcept>);
+static_assert(std::movable<int (S::*)() const&&>);
+static_assert(std::movable<int (S::*)() const && noexcept>);
+static_assert(std::movable<int (S::*)() volatile>);
+static_assert(std::movable<int (S::*)() volatile noexcept>);
+static_assert(std::movable<int (S::*)() volatile&>);
+static_assert(std::movable<int (S::*)() volatile & noexcept>);
+static_assert(std::movable<int (S::*)() volatile&&>);
+static_assert(std::movable<int (S::*)() volatile && noexcept>);
+static_assert(std::movable<int (S::*)() const volatile>);
+static_assert(std::movable<int (S::*)() const volatile noexcept>);
+static_assert(std::movable<int (S::*)() const volatile&>);
+static_assert(std::movable<int (S::*)() const volatile & noexcept>);
+static_assert(std::movable<int (S::*)() const volatile&&>);
+static_assert(std::movable<int (S::*)() const volatile && noexcept>);
+
+static_assert(std::movable<std::deque<int> >);
+static_assert(std::movable<std::forward_list<int> >);
+static_assert(std::movable<std::list<int> >);
+static_assert(std::movable<std::optional<std::vector<int> > >);
+static_assert(std::movable<std::vector<int> >);
+
+static_assert(std::movable<traditional_copy_assignment_only>);
+static_assert(std::movable<has_volatile_member>);
+static_assert(std::movable<has_array_member>);
+
+// Not objects
+static_assert(!std::movable<int&>);
+static_assert(!std::movable<int const&>);
+static_assert(!std::movable<int volatile&>);
+static_assert(!std::movable<int const volatile&>);
+static_assert(!std::movable<int&&>);
+static_assert(!std::movable<int const&&>);
+static_assert(!std::movable<int volatile&&>);
+static_assert(!std::movable<int const volatile&&>);
+static_assert(!std::movable<int()>);
+static_assert(!std::movable<int (&)()>);
+static_assert(!std::movable<int[5]>);
+
+// Core non-move assignable.
+static_assert(!std::movable<int const>);
+static_assert(!std::movable<int const volatile>);
+
+static_assert(!std::movable<DeletedMoveCtor>);
+static_assert(!std::movable<ImplicitlyDeletedMoveCtor>);
+static_assert(!std::movable<DeletedMoveAssign>);
+static_assert(!std::movable<ImplicitlyDeletedMoveAssign>);
+static_assert(!std::movable<NonMovable>);
+static_assert(!std::movable<DerivedFromNonMovable>);
+static_assert(!std::movable<HasANonMovable>);
+
+static_assert(std::movable<cpp03_friendly>);
+static_assert(std::movable<const_move_ctor>);
+static_assert(std::movable<volatile_move_ctor>);
+static_assert(std::movable<cv_move_ctor>);
+static_assert(std::movable<multi_param_move_ctor>);
+static_assert(!std::movable<not_quite_multi_param_move_ctor>);
+
+static_assert(!std::assignable_from<copy_assign_with_mutable_parameter&,
+ copy_assign_with_mutable_parameter>);
+static_assert(!std::movable<copy_assign_with_mutable_parameter>);
+
+static_assert(!std::movable<const_move_assignment>);
+static_assert(std::movable<volatile_move_assignment>);
+static_assert(!std::movable<cv_move_assignment>);
+
+static_assert(!std::movable<const_move_assign_and_traditional_move_assign>);
+static_assert(!std::movable<volatile_move_assign_and_traditional_move_assign>);
+static_assert(!std::movable<cv_move_assign_and_traditional_move_assign>);
+static_assert(std::movable<const_move_assign_and_default_ops>);
+static_assert(std::movable<volatile_move_assign_and_default_ops>);
+static_assert(std::movable<cv_move_assign_and_default_ops>);
+
+static_assert(!std::movable<has_const_member>);
+static_assert(!std::movable<has_cv_member>);
+static_assert(!std::movable<has_lvalue_reference_member>);
+static_assert(!std::movable<has_rvalue_reference_member>);
+static_assert(!std::movable<has_function_ref_member>);
+
+static_assert(std::movable<deleted_assignment_from_const_rvalue>);
+
+// `move_constructible and assignable_from<T&, T>` implies `swappable<T>`,
+// so there's nothing to test for the case of non-swappable.
+
+int main(int, char**) { return 0; }
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// 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_SUPPORT_TYPE_CLASSIFICATION_MOVABLE_H
+#define TEST_SUPPORT_TYPE_CLASSIFICATION_MOVABLE_H
+
+struct has_const_member {
+ int const x;
+};
+
+struct has_volatile_member {
+ int volatile x;
+};
+
+struct has_cv_member {
+ int const volatile x;
+};
+
+struct has_lvalue_reference_member {
+ int& x;
+};
+
+struct has_rvalue_reference_member {
+ int&& x;
+};
+
+struct has_array_member {
+ int x[5];
+};
+
+struct has_function_ref_member {
+ int (&f)();
+};
+
+struct cpp03_friendly {
+ cpp03_friendly(cpp03_friendly const&);
+ cpp03_friendly& operator=(cpp03_friendly const&);
+};
+
+struct const_move_ctor {
+ const_move_ctor(const_move_ctor const&&);
+ const_move_ctor& operator=(const_move_ctor&&);
+};
+
+struct volatile_move_ctor {
+ volatile_move_ctor(volatile_move_ctor volatile&&);
+ volatile_move_ctor& operator=(volatile_move_ctor&&);
+};
+
+struct cv_move_ctor {
+ cv_move_ctor(cv_move_ctor const volatile&&);
+ cv_move_ctor& operator=(cv_move_ctor&&);
+};
+
+struct multi_param_move_ctor {
+ multi_param_move_ctor(multi_param_move_ctor&&, int = 0);
+ multi_param_move_ctor& operator=(multi_param_move_ctor&&);
+};
+
+struct not_quite_multi_param_move_ctor {
+ not_quite_multi_param_move_ctor(not_quite_multi_param_move_ctor&&, int);
+ not_quite_multi_param_move_ctor& operator=(not_quite_multi_param_move_ctor&&);
+};
+
+struct traditional_copy_assignment_only {
+ traditional_copy_assignment_only&
+ operator=(traditional_copy_assignment_only const&);
+};
+
+struct copy_assign_with_mutable_parameter {
+ copy_assign_with_mutable_parameter&
+ operator=(copy_assign_with_mutable_parameter&);
+};
+
+struct const_move_assignment {
+ const_move_assignment& operator=(const_move_assignment&&) const;
+};
+
+struct volatile_move_assignment {
+ const_move_assignment& operator=(const_move_assignment&&) volatile;
+};
+
+struct cv_move_assignment {
+ cv_move_assignment& operator=(cv_move_assignment&&) const volatile;
+};
+
+struct const_move_assign_and_traditional_move_assign {
+ const_move_assign_and_traditional_move_assign&
+ operator=(const_move_assign_and_traditional_move_assign&&);
+ const_move_assign_and_traditional_move_assign&
+ operator=(const_move_assign_and_traditional_move_assign&&) const;
+};
+
+struct volatile_move_assign_and_traditional_move_assign {
+ volatile_move_assign_and_traditional_move_assign&
+ operator=(volatile_move_assign_and_traditional_move_assign&&);
+ volatile_move_assign_and_traditional_move_assign&
+ operator=(volatile_move_assign_and_traditional_move_assign&&) volatile;
+};
+
+struct cv_move_assign_and_traditional_move_assign {
+ cv_move_assign_and_traditional_move_assign&
+ operator=(cv_move_assign_and_traditional_move_assign&&);
+ cv_move_assign_and_traditional_move_assign&
+ operator=(cv_move_assign_and_traditional_move_assign&&) const volatile;
+};
+
+struct const_move_assign_and_default_ops {
+ const_move_assign_and_default_ops(const_move_assign_and_default_ops const&) =
+ default;
+ const_move_assign_and_default_ops(const_move_assign_and_default_ops&&) =
+ default;
+ const_move_assign_and_default_ops&
+ operator=(const_move_assign_and_default_ops const&) = default;
+ const_move_assign_and_default_ops&
+ operator=(const_move_assign_and_default_ops&&) = default;
+ const_move_assign_and_default_ops&
+ operator=(const_move_assign_and_default_ops&&) const;
+};
+
+struct volatile_move_assign_and_default_ops {
+ volatile_move_assign_and_default_ops(
+ volatile_move_assign_and_default_ops const&) = default;
+ volatile_move_assign_and_default_ops(volatile_move_assign_and_default_ops&&) =
+ default;
+ volatile_move_assign_and_default_ops&
+ operator=(volatile_move_assign_and_default_ops const&) = default;
+ volatile_move_assign_and_default_ops&
+ operator=(volatile_move_assign_and_default_ops&&) = default;
+ volatile_move_assign_and_default_ops&
+ operator=(volatile_move_assign_and_default_ops&&) volatile;
+};
+
+struct cv_move_assign_and_default_ops {
+ cv_move_assign_and_default_ops(cv_move_assign_and_default_ops const&) =
+ default;
+ cv_move_assign_and_default_ops(cv_move_assign_and_default_ops&&) = default;
+ cv_move_assign_and_default_ops&
+ operator=(cv_move_assign_and_default_ops const&) = default;
+ cv_move_assign_and_default_ops&
+ operator=(cv_move_assign_and_default_ops&&) = default;
+ cv_move_assign_and_default_ops&
+ operator=(cv_move_assign_and_default_ops&&) const volatile;
+};
+
+struct deleted_assignment_from_const_rvalue {
+ deleted_assignment_from_const_rvalue(
+ deleted_assignment_from_const_rvalue const&);
+ deleted_assignment_from_const_rvalue(deleted_assignment_from_const_rvalue&&);
+ deleted_assignment_from_const_rvalue&
+ operator=(const deleted_assignment_from_const_rvalue&);
+ deleted_assignment_from_const_rvalue&
+ operator=(deleted_assignment_from_const_rvalue&&);
+ deleted_assignment_from_const_rvalue&
+ operator=(const deleted_assignment_from_const_rvalue&&) = delete;
+};
+
+#endif // TEST_SUPPORT_TYPE_CLASSIFICATION_MOVABLE_H
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
-#define TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
+#ifndef TEST_SUPPORT_TYPE_CLASSIFICATION_MOVECONSTRUCTIBLE_H
+#define TEST_SUPPORT_TYPE_CLASSIFICATION_MOVECONSTRUCTIBLE_H
struct HasDefaultOps {};
NonMovable X;
};
-#endif // TEST_STD_CONCEPTS_LAND_MOVECONSTRUCTIBLE_H
+#endif // TEST_SUPPORT_TYPE_CLASSIFICATION_MOVECONSTRUCTIBLE_H
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef TEST_STD_CONCEPTS_LANG_SWAPPABLE_H
-#define TEST_STD_CONCEPTS_LANG_SWAPPABLE_H
+#ifndef TEST_SUPPORT_TYPE_CLASSIFICATION_SWAPPABLE_H
+#define TEST_SUPPORT_TYPE_CLASSIFICATION_SWAPPABLE_H
#include <concepts>
throwable_adl_swappable* this_ = this;
};
-#endif // TEST_STD_CONCEPTS_LANG_SWAPPABLE_H
+#endif // TEST_SUPPORT_TYPE_CLASSIFICATION_SWAPPABLE_H