Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
folly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
folly
Commits
c1be26e5
Commit
c1be26e5
authored
Sep 11, 2015
by
Giuseppe Ottaviano
Committed by
facebook-github-bot-1
Sep 11, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for std::string in folly::Hash
Reviewed By: @liviu Differential Revision: D2436705
parent
2e6f9c9b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
folly/Hash.h
folly/Hash.h
+6
-0
folly/test/HashTest.cpp
folly/test/HashTest.cpp
+7
-1
No files found.
folly/Hash.h
View file @
c1be26e5
...
@@ -375,6 +375,12 @@ template<> struct hasher<uint64_t> {
...
@@ -375,6 +375,12 @@ template<> struct hasher<uint64_t> {
}
}
};
};
template
<
>
struct
hasher
<
std
::
string
>
{
size_t
operator
()(
const
std
::
string
&
key
)
const
{
return
hash
::
SpookyHashV2
::
Hash64
(
key
.
data
(),
key
.
size
(),
0
);
}
};
template
<
class
T
>
template
<
class
T
>
struct
hasher
<
T
,
typename
std
::
enable_if
<
std
::
is_enum
<
T
>::
value
,
void
>::
type
>
{
struct
hasher
<
T
,
typename
std
::
enable_if
<
std
::
is_enum
<
T
>::
value
,
void
>::
type
>
{
size_t
operator
()(
T
key
)
const
{
size_t
operator
()(
T
key
)
const
{
...
...
folly/test/HashTest.cpp
View file @
c1be26e5
...
@@ -303,7 +303,7 @@ TEST(Hash, std_tuple_different_hash) {
...
@@ -303,7 +303,7 @@ TEST(Hash, std_tuple_different_hash) {
std
::
hash
<
tuple3
>
()(
t3
));
std
::
hash
<
tuple3
>
()(
t3
));
}
}
TEST
(
Range
,
Hash
)
{
TEST
(
Hash
,
Strings
)
{
using
namespace
folly
;
using
namespace
folly
;
StringPiece
a1
=
"10050517"
,
b1
=
"51107032"
,
StringPiece
a1
=
"10050517"
,
b1
=
"51107032"
,
...
@@ -329,4 +329,10 @@ TEST(Range, Hash) {
...
@@ -329,4 +329,10 @@ TEST(Range, Hash) {
EXPECT_NE
(
h2
(
w1
),
h2
(
w2
));
EXPECT_NE
(
h2
(
w1
),
h2
(
w2
));
EXPECT_NE
(
h2
(
w1
),
h2
(
w3
));
EXPECT_NE
(
h2
(
w1
),
h2
(
w3
));
EXPECT_NE
(
h2
(
w2
),
h2
(
w4
));
EXPECT_NE
(
h2
(
w2
),
h2
(
w4
));
// Check compatibility with std::string.
EXPECT_EQ
(
h2
(
a1
),
h2
(
a1
.
str
()));
EXPECT_EQ
(
h2
(
a2
),
h2
(
a2
.
str
()));
EXPECT_EQ
(
h2
(
a3
),
h2
(
a3
.
str
()));
EXPECT_EQ
(
h2
(
a4
),
h2
(
a4
.
str
()));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment