]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/64476.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / specialized_algorithms / uninitialized_copy / 64476.cc
CommitLineData
a5544970 1// Copyright (C) 2015-2019 Free Software Foundation, Inc.
0edf5aad
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
52066eae 18// { dg-do run { target c++11 } }
0edf5aad
JW
19
20#include <memory>
21#include <testsuite_hooks.h>
22
23struct X
24{
25 X() = default;
26 X(X const &) = default;
27 X& operator=(X const&) = delete;
28};
29
30static_assert(__is_trivial(X), "X is trivial");
31
32int constructed = 0;
33int assigned = 0;
34
35struct Y
36{
37 Y() = default;
38 Y(Y const &) = default;
39 Y& operator=(Y const&) = default;
40
41 Y(const X&) { ++constructed; }
42 Y& operator=(const X&)& { ++assigned; return *this; }
43 Y& operator=(const X&)&& = delete;
44 Y& operator=(X&&) = delete;
45};
46
47static_assert(__is_trivial(Y), "Y is trivial");
48
49void
50test01()
51{
52 X a[100];
53 Y b[100];
54
55 std::uninitialized_copy(a, a+10, b);
56
57 VERIFY(constructed == 0);
58 VERIFY(assigned == 10);
59}
60
61int
62main()
63{
64 test01();
65}