xref: /llvm-project/libcxx/test/std/ranges/range.factories/range.single.view/assign.pass.cpp (revision b8cb1dc9ea87faa8e8e9ab7a31710a8c0bb8b084)
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 
11 // Tests that <value_> is a <copyable-box>.
12 
13 #include <cassert>
14 #include <ranges>
15 #include <utility>
16 
17 #include "test_macros.h"
18 
19 struct NotAssignable {
20   NotAssignable() = default;
21   NotAssignable(const NotAssignable&) = default;
22   NotAssignable(NotAssignable&&) = default;
23 
24   NotAssignable& operator=(const NotAssignable&) = delete;
25   NotAssignable& operator=(NotAssignable&&) = delete;
26 };
27 
test()28 constexpr bool test() {
29   const std::ranges::single_view<NotAssignable> a;
30   std::ranges::single_view<NotAssignable> b;
31   b = a;
32   b = std::move(a);
33 
34   return true;
35 }
36 
main(int,char **)37 int main(int, char**) {
38   test();
39   static_assert(test());
40 
41   return 0;
42 }
43