1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <set>
10
11// set()
12// noexcept(
13// is_nothrow_default_constructible<allocator_type>::value &&
14// is_nothrow_default_constructible<key_compare>::value &&
15// is_nothrow_copy_constructible<key_compare>::value);
16
17// This tests a conforming extension
18
19// UNSUPPORTED: c++03
20
21#include <set>
22#include <cassert>
23
24#include "test_macros.h"
25#include "MoveOnly.h"
26#include "test_allocator.h"
27
28template <class T>
29struct some_comp
30{
31 typedef T value_type;
32 some_comp();
33 bool operator()(const T&, const T&) const { return false; }
34};
35
36int main(int, char**)
37{
38#if defined(_LIBCPP_VERSION)
39 {
40 typedef std::set<MoveOnly> C;
41 static_assert(std::is_nothrow_default_constructible<C>::value, "");
42 }
43 {
44 typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
45 static_assert(std::is_nothrow_default_constructible<C>::value, "");
46 }
47#endif // _LIBCPP_VERSION
48 {
49 typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
50 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
51 }
52 {
53 typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
54 static_assert(!std::is_nothrow_default_constructible<C>::value, "");
55 }
56
57 return 0;
58}
59

source code of libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp