brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 8e3abf0 Raw
41 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// UNSUPPORTED: c++03, c++11, c++14, c++1710 11#include <map>12#include <string>13 14#include "associative_container_benchmarks.h"15#include "../../GenerateInput.h"16#include "benchmark/benchmark.h"17 18template <class K, class V>19struct support::adapt_operations<std::multimap<K, V>> {20  using ValueType = typename std::multimap<K, V>::value_type;21  using KeyType   = typename std::multimap<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 = typename std::multimap<K, V>::iterator;26  static auto get_iterator(InsertionResult const& result) { return result; }27 28  template <class Allocator>29  using rebind_alloc = std::multimap<K, V, std::less<K>, Allocator>;30};31 32int main(int argc, char** argv) {33  support::associative_container_benchmarks<std::multimap<int, int>>("std::multimap<int, int>");34  support::associative_container_benchmarks<std::multimap<std::string, int>>("std::multimap<std::string, int>");35 36  benchmark::Initialize(&argc, argv);37  benchmark::RunSpecifiedBenchmarks();38  benchmark::Shutdown();39  return 0;40}41