blob: 1be3ed2b887732cc50de9b7b972d7cddd6c72402 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <set>
11
12// class set
13
Marshall Clow934e9a32018-08-22 04:28:43 +000014// void clear() noexcept;
Howard Hinnant3e519522010-05-11 19:42:16 +000015
16#include <set>
17#include <cassert>
18
Marshall Clow934e9a32018-08-22 04:28:43 +000019#include "test_macros.h"
Marshall Clowe34f6f62013-11-26 20:58:02 +000020#include "min_allocator.h"
Howard Hinnant07d3ecc2013-06-19 21:29:40 +000021
Howard Hinnant3e519522010-05-11 19:42:16 +000022int main()
23{
24 {
25 typedef std::set<int> M;
26 typedef int V;
27 V ar[] =
28 {
29 1,
30 2,
31 3,
32 4,
33 5,
34 6,
35 7,
36 8
37 };
38 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
39 assert(m.size() == 8);
Marshall Clow934e9a32018-08-22 04:28:43 +000040 ASSERT_NOEXCEPT(m.clear());
Howard Hinnant3e519522010-05-11 19:42:16 +000041 m.clear();
42 assert(m.size() == 0);
43 }
Eric Fiselierf2f2a632016-06-14 21:31:42 +000044#if TEST_STD_VER >= 11
Howard Hinnant07d3ecc2013-06-19 21:29:40 +000045 {
46 typedef std::set<int, std::less<int>, min_allocator<int>> M;
47 typedef int V;
48 V ar[] =
49 {
50 1,
51 2,
52 3,
53 4,
54 5,
55 6,
56 7,
57 8
58 };
59 M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
60 assert(m.size() == 8);
Marshall Clow934e9a32018-08-22 04:28:43 +000061 ASSERT_NOEXCEPT(m.clear());
Howard Hinnant07d3ecc2013-06-19 21:29:40 +000062 m.clear();
63 assert(m.size() == 0);
64 }
65#endif
Howard Hinnant3e519522010-05-11 19:42:16 +000066}