]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 24_iterators / customization_points / iter_move.cc
CommitLineData
a945c346 1// Copyright (C) 2019-2024 Free Software Foundation, Inc.
6d0dff49
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
762baaf0 18// { dg-do run { target c++20 } }
6d0dff49
JW
19
20#include <iterator>
21#include <testsuite_hooks.h>
b9e35ee6
JW
22#include <testsuite_iterators.h>
23
24static_assert(__gnu_test::is_customization_point_object(std::ranges::iter_move));
6d0dff49
JW
25
26struct X
27{
28 int value;
29
30 constexpr X(int i) : value(i) { }
31
32 X(const X&) = default;
33 X& operator=(const X&) = default;
34
35 constexpr X(X&& x)
36 : value(x.value)
37 {
38 x.value = -2;
39 }
40
41 constexpr X& operator=(X&& x)
42 {
43 value = x.value;
44 x.value = -1;
45 return *this;
46 }
47};
48
49constexpr bool
50test_X(int i, int j)
51{
52 X x1{i}, x2{j};
240b01b0 53 (void) std::ranges::iter_move(&x1); // no-op
6d0dff49
JW
54 x1 = std::ranges::iter_move(&x2);
55 return x1.value == j && x2.value == -1;
56}
57
58static_assert( test_X(1, 2) );
59
60void
61test01()
62{
63 VERIFY( test_X(3, 4) );
64}
65
66int
67main()
68{
69 test01();
70}