• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <set>
11 
12 // class set
13 
14 // void clear() noexcept;
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "min_allocator.h"
21 
main()22 int 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);
40         ASSERT_NOEXCEPT(m.clear());
41         m.clear();
42         assert(m.size() == 0);
43     }
44 #if TEST_STD_VER >= 11
45     {
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);
61         ASSERT_NOEXCEPT(m.clear());
62         m.clear();
63         assert(m.size() == 0);
64     }
65 #endif
66 }
67