#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:
#pragma once
+#include <functional>
#include <initializer_list>
#include <memory>
#include <unordered_set>
+#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 set
*/
-template <class Hasher = StringPieceHash,
- class Eq = std::equal_to<StringPiece>,
- class Alloc = std::allocator<folly::StringPiece>>
+template <
+ class Hasher = Hash,
+ class Eq = std::equal_to<StringPiece>,
+ class Alloc = std::allocator<folly::StringPiece>>
class BasicStringKeyedUnorderedSet
: private std::unordered_set<StringPiece, Hasher, Eq, Alloc> {
using Base = std::unordered_set<StringPiece, Hasher, Eq, Alloc>;
#include <glog/logging.h>
+#include <folly/Hash.h>
#include <folly/Range.h>
#include <folly/portability/GFlags.h>
#include <folly/portability/GTest.h>
typedef MemoryLeakCheckerAllocator<
std::allocator<std::pair<const StringPiece, int>>> ValueLeakChecker;
-typedef StringKeyedUnorderedMap<int, folly::StringPieceHash,
- std::equal_to<StringPiece>, ValueLeakChecker>
- LeakCheckedUnorderedMap;
+typedef StringKeyedUnorderedMap<
+ int,
+ folly::Hash,
+ std::equal_to<StringPiece>,
+ ValueLeakChecker>
+ LeakCheckedUnorderedMap;
-typedef StringKeyedSetBase<std::less<StringPiece>, ValueLeakChecker> LeakCheckedSet;
+typedef StringKeyedSetBase<std::less<StringPiece>, ValueLeakChecker>
+ LeakCheckedSet;
-typedef StringKeyedMap<int, std::less<StringPiece>,
- ValueLeakChecker> LeakCheckedMap;
+typedef StringKeyedMap<int, std::less<StringPiece>, ValueLeakChecker>
+ LeakCheckedMap;
using LeakCheckedUnorderedSet = BasicStringKeyedUnorderedSet<
- folly::StringPieceHash,
- std::equal_to<folly::StringPiece>,
- ValueLeakChecker>;
+ folly::Hash,
+ std::equal_to<folly::StringPiece>,
+ ValueLeakChecker>;
TEST(StringKeyedUnorderedMapTest, sanity) {
LeakCheckedUnorderedMap map;