brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 4f70d26 Raw
44 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// REQUIRES: std-at-least-c++2310 11#include <flat_map>12 13#include "associative_container_benchmarks.h"14#include "../../GenerateInput.h"15#include "benchmark/benchmark.h"16 17template <class K, class V>18struct support::adapt_operations<std::flat_multimap<K, V>> {19  using ValueType = typename std::flat_multimap<K, V>::value_type;20  using KeyType   = typename std::flat_multimap<K, V>::key_type;21  static ValueType value_from_key(KeyType const& k) { return {k, Generate<V>::arbitrary()}; }22  static KeyType key_from_value(ValueType const& value) { return value.first; }23 24  using InsertionResult = typename std::flat_multimap<K, V>::iterator;25  static auto get_iterator(InsertionResult const& result) { return result; }26 27  template <class Allocator>28  using rebind_alloc =29      std::flat_multimap<K,30                         V,31                         std::less<K>,32                         std::vector<K, typename std::allocator_traits<Allocator>::template rebind_alloc<K>>,33                         std::vector<V, typename std::allocator_traits<Allocator>::template rebind_alloc<V>>>;34};35 36int main(int argc, char** argv) {37  support::associative_container_benchmarks<std::flat_multimap<int, int>>("std::flat_multimap<int, int>");38 39  benchmark::Initialize(&argc, argv);40  benchmark::RunSpecifiedBenchmarks();41  benchmark::Shutdown();42  return 0;43}44