From b5058c7e75971ba7c03b277408b9bdbc98d21a6d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 9 Feb 2006 19:11:54 +0000 Subject: [PATCH] Hold your nose, it's a Visual C++ 6.5 workaround. For some reason it requires boost::hash to define operator() taking const and non-const arguments. [SVN r32783] --- include/boost/functional/hash/hash.hpp | 64 +++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 7 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index b54d551..f28052d 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -24,6 +24,10 @@ #include #endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) +#include +#endif + namespace boost { #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) @@ -310,6 +314,7 @@ namespace boost // boost::hash +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) template struct hash : std::unary_function { @@ -323,15 +328,60 @@ namespace boost { return hash_detail::call_hash::call(val); } - -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - std::size_t operator()(T& val) const - { - return hash_detail::call_hash::call(val); - } -#endif #endif }; + +#else // Visual C++ 6.5 + // There's probably a more elegant way to Visual C++ 6.5 to work + // but I don't know what it is. + + namespace hash_detail + { + template + struct hash_impl_base + : std::unary_function + { + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } + }; + + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner : public hash_impl_base {}; + }; + + template <> + struct hash_impl + { + template + struct inner : public hash_impl_base + { + std::size_t operator()(T const& val) const + { + return hash_impl_base::operator()(val); + } + + std::size_t operator()(T& val) const + { + return hash_impl_base::operator()(val); + } + }; + }; + } + + template struct hash + : public hash_detail::hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; +#endif } #endif