1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
16 // requires assignable_from<S&, const S2&>
17 // constexpr move_sentinel& operator=(const move_sentinel<S2>& s);
22 #include <type_traits>
24 struct NonAssignable
{
25 NonAssignable
& operator=(int i
);
27 static_assert(std::semiregular
<NonAssignable
>);
28 static_assert(std::is_assignable_v
<NonAssignable
, int>);
29 static_assert(!std::assignable_from
<NonAssignable
, int>);
33 // Assigning from an lvalue.
35 std::move_sentinel
<int> m(42);
36 std::move_sentinel
<long> m2
;
38 assert(m2
.base() == 42L);
41 // Assigning from an rvalue.
43 std::move_sentinel
<long> m2
;
44 m2
= std::move_sentinel
<int>(43);
45 assert(m2
.base() == 43L);
50 static_assert( std::is_assignable_v
<std::move_sentinel
<int>, std::move_sentinel
<long>>);
51 static_assert(!std::is_assignable_v
<std::move_sentinel
<int*>, std::move_sentinel
<const int*>>);
52 static_assert( std::is_assignable_v
<std::move_sentinel
<const int*>, std::move_sentinel
<int*>>);
53 static_assert(!std::is_assignable_v
<std::move_sentinel
<NonAssignable
>, std::move_sentinel
<int>>);
61 static_assert(test());