From 25a41ae31bf58509e434c63e55029145a27841d2 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 4 Sep 2014 19:38:53 -0700 Subject: [PATCH] restore value hash + add test harness --- include/mapnik/value.hpp | 6 ++++++ tests/cpp_tests/conversions_test.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index dc64ab609..6fdca6583 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -937,6 +937,12 @@ operator << (std::basic_ostream& out, return out; } +// hash function +inline std::size_t hash_value(value const& val) +{ + return hash_value(val); +} + } // namespace value_adl_barrier using value_adl_barrier::value; diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index 6f750840a..cb9d0d4fd 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -1,9 +1,11 @@ #include +#include #include #include #include #include #include +#include #if defined(_MSC_VER) && _MSC_VER < 1900 #include @@ -282,6 +284,14 @@ int main(int argc, char** argv) BOOST_TEST_EQ( val, false ); BOOST_TEST( string2bool("true",val) ); BOOST_TEST_EQ( val, true ); + + // mapnik::value hashability + using values_container = boost::unordered_map; + values_container vc; + mapnik::value val2(1); + vc[val2] = 1; + BOOST_TEST_EQ( vc[1], 1 ); + } catch (std::exception const & ex) {