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// <unordered_map>
10
11// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
12// class Alloc = allocator<pair<const Key, T>>>
13// class unordered_map
14
15// float max_load_factor() const;
16// void max_load_factor(float mlf);
17
18#include <unordered_map>
19#include <string>
20#include <cassert>
21
22#include "test_macros.h"
23#include "min_allocator.h"
24
25int main(int, char**)
26{
27 {
28 typedef std::unordered_map<int, std::string> C;
29 const C c;
30 assert(c.max_load_factor() == 1);
31 }
32 {
33 typedef std::unordered_map<int, std::string> C;
34 C c;
35 assert(c.max_load_factor() == 1);
36 c.max_load_factor(z: 2.5);
37 assert(c.max_load_factor() == 2.5);
38 }
39#if TEST_STD_VER >= 11
40 {
41 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
42 min_allocator<std::pair<const int, std::string>>> C;
43 const C c;
44 assert(c.max_load_factor() == 1);
45 }
46 {
47 typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
48 min_allocator<std::pair<const int, std::string>>> C;
49 C c;
50 assert(c.max_load_factor() == 1);
51 c.max_load_factor(2.5);
52 assert(c.max_load_factor() == 2.5);
53 }
54#endif
55
56 return 0;
57}
58

source code of libcxx/test/std/containers/unord/unord.map/max_load_factor.pass.cpp