//===----------------------------------------------------------------------===// // // 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 // // move_sentinel // template // requires assignable_from // constexpr move_sentinel& operator=(const move_sentinel& s); #include #include #include struct NonAssignable { NonAssignable& operator=(int i); }; static_assert(std::semiregular); static_assert(std::is_assignable_v); static_assert(!std::assignable_from); constexpr bool test() { // Assigning from an lvalue. { std::move_sentinel m(42); std::move_sentinel m2; m2 = m; assert(m2.base() == 42L); } // Assigning from an rvalue. { std::move_sentinel m2; m2 = std::move_sentinel(43); assert(m2.base() == 43L); } // SFINAE checks. { static_assert( std::is_assignable_v, std::move_sentinel>); static_assert(!std::is_assignable_v, std::move_sentinel>); static_assert( std::is_assignable_v, std::move_sentinel>); static_assert(!std::is_assignable_v, std::move_sentinel>); } return true; } int main(int, char**) { test(); static_assert(test()); return 0; }