Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / unord / unord.set / load_factor.pass.cpp
blob0952a4c3f2134b1d4fc6250f8bbd9d88ef1fd557
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 //===----------------------------------------------------------------------===//
9 // <unordered_set>
11 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12 // class Alloc = allocator<Value>>
13 // class unordered_set
15 // float load_factor() const
17 #include <unordered_set>
18 #include <cassert>
19 #include <cfloat>
20 #include <cmath>
22 #include "test_macros.h"
23 #include "min_allocator.h"
25 int main(int, char**)
28 typedef std::unordered_set<int> C;
29 typedef int P;
30 P a[] =
32 P(10),
33 P(20),
34 P(30),
35 P(40),
36 P(50),
37 P(60),
38 P(70),
39 P(80)
41 const C c(std::begin(a), std::end(a));
42 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
45 typedef std::unordered_set<int> C;
46 const C c;
47 assert(c.load_factor() == 0);
49 #if TEST_STD_VER >= 11
51 typedef std::unordered_set<int, std::hash<int>,
52 std::equal_to<int>, min_allocator<int>> C;
53 typedef int P;
54 P a[] =
56 P(10),
57 P(20),
58 P(30),
59 P(40),
60 P(50),
61 P(60),
62 P(70),
63 P(80)
65 const C c(std::begin(a), std::end(a));
66 assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
69 typedef std::unordered_set<int, std::hash<int>,
70 std::equal_to<int>, min_allocator<int>> C;
71 const C c;
72 assert(c.load_factor() == 0);
74 #endif
76 return 0;