Fix addvdi3 and subvdi3 patterns
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_set / 92124.cc
blob8382a00ff2588c1a71ba81f025bff23f5813fbcd
1 // Copyright (C) 2020-2022 Free Software Foundation, Inc.
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.
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.
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/>.
18 // { dg-do run { target c++11 } }
20 #include <unordered_set>
22 #include <testsuite_allocator.h>
23 #include <testsuite_hooks.h>
25 int moves = 0;
27 struct X
29 X() = default;
30 X(const X&) = default;
31 X(int i) : _i(i) {}
33 // Move constructor might throw
34 X(X&& x) noexcept(false)
36 this->_i = x._i;
37 x._i = -1;
38 ++moves;
41 int _i;
44 struct XHasher
46 std::size_t
47 operator()(const X& x) const noexcept
48 { return x._i; }
51 struct XEqualTo
53 bool
54 operator()(const X& lhs, const X& rhs) const noexcept
55 { return lhs._i == rhs._i; }
58 void
59 test01()
61 using A = __gnu_test::propagating_allocator<X, false>;
62 A a1(1), a2(2);
63 std::unordered_set<X, XHasher, XEqualTo, A> u1(a1), u2(a2);
64 u1 = { X(0), X(1), X(2) };
65 u2 = { X(3), X(4), X(5) };
67 moves = 0;
68 u1 = std::move(u2);
70 VERIFY( moves == 3 );
71 VERIFY( u1.count(X(1)) == 0 );
72 VERIFY( u1.count(X(3)) == 1 );
75 int
76 main()
78 test01();