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