/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// Copyright 2013-present Facebook. All Rights Reserved.
// @author: Pavlo Kushnir (pavlo)
-#ifndef FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_
-#define FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_
+#pragma once
+#include <functional>
#include <initializer_list>
#include <memory>
#include <unordered_map>
+#include <utility>
+
+#include <folly/Hash.h>
#include <folly/Range.h>
#include <folly/experimental/StringKeyedCommon.h>
* It uses kind of hack: string pointed by StringPiece is copied when
* StringPiece is inserted into map
*/
-template <class Value,
- class Hash = StringPieceHash,
- class Eq = std::equal_to<StringPiece>,
- class Alloc = std::allocator<std::pair<const StringPiece, Value>>>
+template <
+ class Value,
+ class Hash = Hash,
+ class Eq = std::equal_to<StringPiece>,
+ class Alloc = std::allocator<std::pair<const StringPiece, Value>>>
class StringKeyedUnorderedMap
: private std::unordered_map<StringPiece, Value, Hash, Eq, Alloc> {
-private:
+ private:
using Base = std::unordered_map<StringPiece, Value, Hash, Eq, Alloc>;
public:
typedef typename Base::size_type size_type;
typedef typename Base::difference_type difference_type;
- explicit StringKeyedUnorderedMap() {}
+ explicit StringKeyedUnorderedMap() = default;
explicit StringKeyedUnorderedMap(
size_type n,
}
StringKeyedUnorderedMap(StringKeyedUnorderedMap&& other,
- const allocator_type& a) noexcept
- : Base(std::move(other)/*, a*/ /* not supported by gcc */) {
- }
+ const allocator_type& /* a */) noexcept
+ : Base(std::move(other) /*, a*/ /* not supported by gcc */) {}
StringKeyedUnorderedMap(std::initializer_list<value_type> il)
: StringKeyedUnorderedMap(il.begin(), il.end()) {
using Base::at;
using Base::find;
+ using Base::count;
template <class... Args>
std::pair<iterator, bool> emplace(StringPiece key, Args&&... args) {
};
} // folly
-
-#endif /* FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_ */