mirror of
https://github.com/boostorg/functional.git
synced 2025-08-02 14:04:27 +02:00
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]
This commit is contained in:
@@ -24,6 +24,10 @@
|
|||||||
#include <boost/type_traits/is_array.hpp>
|
#include <boost/type_traits/is_array.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
|
#include <boost/type_traits/is_const.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||||
@@ -310,6 +314,7 @@ namespace boost
|
|||||||
|
|
||||||
// boost::hash
|
// boost::hash
|
||||||
|
|
||||||
|
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
template <class T> struct hash
|
template <class T> struct hash
|
||||||
: std::unary_function<T, std::size_t>
|
: std::unary_function<T, std::size_t>
|
||||||
{
|
{
|
||||||
@@ -323,15 +328,60 @@ namespace boost
|
|||||||
{
|
{
|
||||||
return hash_detail::call_hash<T>::call(val);
|
return hash_detail::call_hash<T>::call(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
|
||||||
std::size_t operator()(T& val) const
|
|
||||||
{
|
|
||||||
return hash_detail::call_hash<T>::call(val);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#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 <class T>
|
||||||
|
struct hash_impl_base
|
||||||
|
: std::unary_function<T, std::size_t>
|
||||||
|
{
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_detail::call_hash<T>::call(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool IsConst>
|
||||||
|
struct hash_impl;
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct hash_impl<true>
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct inner : public hash_impl_base<T> {};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct hash_impl<false>
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct inner : public hash_impl_base<T>
|
||||||
|
{
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_impl_base<T>::operator()(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t operator()(T& val) const
|
||||||
|
{
|
||||||
|
return hash_impl_base<T>::operator()(val);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T> struct hash
|
||||||
|
: public hash_detail::hash_impl<boost::is_const<T>::value>
|
||||||
|
::BOOST_NESTED_TEMPLATE inner<T>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user