diff --git a/.travis.yml b/.travis.yml index ab048db..1e0f8fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -192,6 +192,9 @@ install: - git submodule update --init libs/static_assert - git submodule update --init libs/throw_exception - git submodule update --init libs/type_traits + - git submodule update --init libs/container_hash + - git submodule update --init libs/integer + - git submodule update --init libs/detail - cp -r $TRAVIS_BUILD_DIR/* libs/utility - ./bootstrap.sh - ./b2 headers diff --git a/appveyor.yml b/appveyor.yml index 77623f0..b63ff9f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,6 +36,9 @@ install: - git submodule update --init libs/static_assert - git submodule update --init libs/throw_exception - git submodule update --init libs/type_traits + - git submodule update --init libs/container_hash + - git submodule update --init libs/integer + - git submodule update --init libs/detail - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\utility - cmd /c bootstrap - b2 -d0 headers diff --git a/include/boost/utility/string_view.hpp b/include/boost/utility/string_view.hpp index 44efda9..11aa801 100644 --- a/include/boost/utility/string_view.hpp +++ b/include/boost/utility/string_view.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -690,6 +691,10 @@ namespace boost { } #endif + template + std::size_t hash_value(basic_string_view s) { + return boost::hash_range(s.begin(), s.end()); + } } #if 0 diff --git a/test/string_view_test1.cpp b/test/string_view_test1.cpp index 9b70a7e..c35bbfa 100644 --- a/test/string_view_test1.cpp +++ b/test/string_view_test1.cpp @@ -12,6 +12,7 @@ #include #include +#include #include @@ -85,6 +86,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 hstr; + boost::hash hsv; + BOOST_TEST(hsv(ref) == hstr(str)); + } + const char *test_strings [] = { "", "1", @@ -102,6 +111,7 @@ int main() test_substr ( *p ); test_remove ( *p ); null_tests ( *p ); + test_hash( *p ); p++; }