On a strictly standards compliant compiler, an overload defined in the boost
namespace won't be found when Let's say we have a simple custom type: namespace foo
{
template <class T>
class custom_type
{
T value;
public:
custom_type(T x) : value(x) {}
friend std::size_t hash_value(custom_type x)
{
On a compliant compiler, when So first move the member function out of the class: namespace foo
{
template <class T>
class custom_type
{
T value;
public:
custom_type(T x) : value(x) {}
std::size_t hash(custom_type x)
{
Unfortunately, I couldn't declare hash_value as a friend, as some compilers don't support template friends, so instead I declared a member function to calculate the hash, and called it from hash_value. For compilers which don't support ADL, hash_value needs to be defined in the boost namespace: #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP namespace boost #else namespace foo #endif { template <class T> std::size_t hash_value(foo::custom_type<T> x) { return x.hash(); } } Full code for this example is at /libs/functional/hash/examples/portable.cpp. Other Issues
On Visual C++ versions 6.5 and 7.0, On Visual C++ versions 6.5 and 7.0, function pointers aren't currently supported.
When using GCC on Solaris, |