]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/unordered_set/cons/noexcept_move_construct.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / unordered_set / cons / noexcept_move_construct.cc
1 // { dg-do compile { target c++11 } }
2
3 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 #include <unordered_set>
21
22 using type1 = std::unordered_set<int>;
23
24 static_assert( std::is_nothrow_move_constructible<type1>::value,
25 "noexcept move constructor" );
26 static_assert( std::is_nothrow_constructible<type1,
27 type1&&, const typename type1::allocator_type&>::value,
28 "noexcept move constructor with allocator" );
29
30 struct not_noexcept_copy_cons_hash
31 {
32 not_noexcept_copy_cons_hash() noexcept;
33 not_noexcept_copy_cons_hash(const not_noexcept_copy_cons_hash&) /* noexcept */;
34 not_noexcept_copy_cons_hash(not_noexcept_copy_cons_hash&&) noexcept;
35
36 std::size_t
37 operator()(int) const noexcept;
38 };
39
40 using type2 = std::unordered_set<int, not_noexcept_copy_cons_hash>;
41
42 static_assert( !std::is_nothrow_move_constructible<type2>::value,
43 "not noexcept move constructor" );
44 static_assert( !std::is_nothrow_constructible<type2, type2&&,
45 const typename type2::allocator_type&>::value,
46 "not noexcept move constructor with allocator" );
47
48 struct not_noexcept_copy_cons_equal_to
49 {
50 not_noexcept_copy_cons_equal_to() noexcept;
51 not_noexcept_copy_cons_equal_to(const not_noexcept_copy_cons_equal_to&) /* noexcept */;
52 not_noexcept_copy_cons_equal_to(not_noexcept_copy_cons_equal_to&&) noexcept;
53
54 bool
55 operator()(int, int) const noexcept;
56 };
57
58 using type3 = std::unordered_set<int, std::hash<int>,
59 not_noexcept_copy_cons_equal_to>;
60
61 static_assert( !std::is_nothrow_move_constructible<type3>::value,
62 "not noexcept move constructor" );
63 static_assert( !std::is_nothrow_constructible<type3, type3&&,
64 const typename type3::allocator_type&>::value,
65 "not noexcept move constructor with allocator" );