X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fexperimental%2FStringKeyedUnorderedMap.h;h=7099332ab3fc66207e79481b36d7b3df6f5186c0;hp=e31f96f5db55abc0479d6f9c0d0800ced298b82e;hb=1e6a1dce8fa0c0132661a4858b422be14c425dad;hpb=321542683a01c3f334047531e9b487f047129775 diff --git a/folly/experimental/StringKeyedUnorderedMap.h b/folly/experimental/StringKeyedUnorderedMap.h index e31f96f5..7099332a 100644 --- a/folly/experimental/StringKeyedUnorderedMap.h +++ b/folly/experimental/StringKeyedUnorderedMap.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +16,15 @@ // Copyright 2013-present Facebook. All Rights Reserved. // @author: Pavlo Kushnir (pavlo) -#ifndef FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_ -#define FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_ +#pragma once +#include #include #include #include +#include + +#include #include #include @@ -34,13 +37,14 @@ namespace folly { * It uses kind of hack: string pointed by StringPiece is copied when * StringPiece is inserted into map */ -template , - class Alloc = std::allocator>> +template < + class Value, + class Hash = Hash, + class Eq = std::equal_to, + class Alloc = std::allocator>> class StringKeyedUnorderedMap : private std::unordered_map { -private: + private: using Base = std::unordered_map; public: @@ -147,11 +151,16 @@ public: using Base::cbegin; using Base::cend; - bool operator==(const StringKeyedUnorderedMap& rhs) { - const Base& lhs = *this; + bool operator==(StringKeyedUnorderedMap const& other) const { + Base const& lhs = *this; + Base const& rhs = static_cast(other); return lhs == rhs; } + void swap(StringKeyedUnorderedMap& other) & { + return Base::swap(other); + } + // No need for copy/move overload as StringPiece is small struct. mapped_type& operator[](StringPiece key) { auto it = find(key); @@ -165,6 +174,7 @@ public: using Base::at; using Base::find; + using Base::count; template std::pair emplace(StringPiece key, Args&&... args) { @@ -227,5 +237,3 @@ public: }; } // folly - -#endif /* FOLLY_EXPERIMENTAL_STRINGKEYEDUNORDEREDMAP_H_ */