Implement boost hash for string_view

This commit is contained in:
Dimitrij Mijoski
2018-04-20 13:42:07 +02:00
parent 7709f0e430
commit 6ad6bc005c
4 changed files with 16 additions and 0 deletions

View File

@@ -85,6 +85,14 @@ void test_remove ( const std::string &str ) {
}
}
void test_hash(const std::string& str) {
string_view ref = str;
BOOST_TEST(boost::hash_value(ref) == boost::hash_value(str));
boost::hash<std::string> hstr;
boost::hash<string_view> hsv;
BOOST_TEST(hsv(ref) == hstr(str));
}
const char *test_strings [] = {
"",
"1",
@@ -102,6 +110,7 @@ int main()
test_substr ( *p );
test_remove ( *p );
null_tests ( *p );
test_hash( *p );
p++;
}