brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 1b66633 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 <string>12#include <unordered_set>13#include <utility>14 15#include "associative_container_benchmarks.h"16#include "benchmark/benchmark.h"17 18template <class K>19struct support::adapt_operations<std::unordered_set<K>> {20  using ValueType = typename std::unordered_set<K>::value_type;21  using KeyType   = typename std::unordered_set<K>::key_type;22  static ValueType value_from_key(KeyType const& k) { return k; }23  static KeyType key_from_value(ValueType const& value) { return value; }24 25  using InsertionResult = std::pair<typename std::unordered_set<K>::iterator, bool>;26  static auto get_iterator(InsertionResult const& result) { return result.first; }27 28  template <class Allocator>29  using rebind_alloc = std::unordered_set<K, std::hash<K>, std::equal_to<K>, Allocator>;30};31 32int main(int argc, char** argv) {33  support::associative_container_benchmarks<std::unordered_set<int>>("std::unordered_set<int>");34  support::associative_container_benchmarks<std::unordered_set<std::string>>("std::unordered_set<std::string>");35 36  benchmark::Initialize(&argc, argv);37  benchmark::RunSpecifiedBenchmarks();38  benchmark::Shutdown();39  return 0;40}41