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 | // REQUIRES: std-at-least-c++26 |
10 | |
11 | #include <flat_map> |
12 | #include <utility> |
13 | |
14 | #include "associative_container_benchmarks.h" |
15 | #include "../../GenerateInput.h" |
16 | #include "benchmark/benchmark.h" |
17 | |
18 | template <class K, class V> |
19 | struct support::adapt_operations<std::flat_map<K, V>> { |
20 | using ValueType = typename std::flat_map<K, V>::value_type; |
21 | using KeyType = typename std::flat_map<K, V>::key_type; |
22 | static ValueType value_from_key(KeyType const& k) { return {k, Generate<V>::arbitrary()}; } |
23 | static KeyType key_from_value(ValueType const& value) { return value.first; } |
24 | |
25 | using InsertionResult = std::pair<typename std::flat_map<K, V>::iterator, bool>; |
26 | static auto get_iterator(InsertionResult const& result) { return result.first; } |
27 | }; |
28 | |
29 | int main(int argc, char** argv) { |
30 | support::associative_container_benchmarks<std::flat_map<int, int>>("std::flat_map<int, int>" ); |
31 | |
32 | benchmark::Initialize(&argc, argv); |
33 | benchmark::RunSpecifiedBenchmarks(); |
34 | benchmark::Shutdown(); |
35 | return 0; |
36 | } |
37 | |