| 1 |
// Copyright (C) 2020-2025 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. |
| 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 |
|
| 18 |
// { dg-do compile { target c++11 } } |
| 19 |
|
| 20 |
#include <unordered_set> |
| 21 |
|
| 22 |
using type1 = std::unordered_set<int>; |
| 23 |
|
| 24 |
static_assert(std::is_nothrow_default_constructible<type1>::value, |
| 25 |
"noexcept default constructible"); |
| 26 |
|
| 27 |
struct not_noexcept_dflt_cons_hash |
| 28 |
{ |
| 29 |
not_noexcept_dflt_cons_hash() /* noexcept */; |
| 30 |
|
| 31 |
std::size_t |
| 32 |
operator()(int) const noexcept; |
| 33 |
}; |
| 34 |
|
| 35 |
using type2 = std::unordered_set<int, not_noexcept_dflt_cons_hash>; |
| 36 |
|
| 37 |
static_assert( !std::is_nothrow_default_constructible<type2>::value, |
| 38 |
"not noexcept default constructible"); |
| 39 |
|
| 40 |
struct not_noexcept_dflt_cons_equal_to |
| 41 |
{ |
| 42 |
not_noexcept_dflt_cons_equal_to() /* noexcept */; |
| 43 |
|
| 44 |
bool |
| 45 |
operator()(int, int) const noexcept; |
| 46 |
}; |
| 47 |
|
| 48 |
using type3 = std::unordered_set<int, std::hash<int>, |
| 49 |
not_noexcept_dflt_cons_equal_to>; |
| 50 |
|
| 51 |
static_assert( !std::is_nothrow_default_constructible<type3>::value, |
| 52 |
"not noexcept default constructible"); |
| 53 |
|
| 54 |
template<typename _Tp> |
| 55 |
struct not_noexcept_dflt_cons_alloc : std::allocator<_Tp> |
| 56 |
{ |
| 57 |
not_noexcept_dflt_cons_alloc() /* noexcept */; |
| 58 |
|
| 59 |
template<typename _Tp1> |
| 60 |
struct rebind |
| 61 |
{ typedef not_noexcept_dflt_cons_alloc<_Tp1> other; }; |
| 62 |
}; |
| 63 |
|
| 64 |
using type4 = std::unordered_set<int, std::hash<int>, std::equal_to<int>, |
| 65 |
not_noexcept_dflt_cons_alloc<int>>; |
| 66 |
|
| 67 |
static_assert(!std::is_nothrow_default_constructible<type4>::value, |
| 68 |
"not noexcept default constructible"); |