Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-04-11 03:04:24

David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>> Daniel James wrote:
>>> I've just checked in an attempt at supporting built-in arrays in
>>> boost::hash. It's not great and I might remove it before Friday. My
>>> main problem was that overloading hash_value for both T* and T[Size]
>>> causes ambiguity -
> Array types in function parameter lists decay to pointers, so of
> course that's ambiguous. Maybe you mean
> template <class T, std::size_t N>
> size_t hash_value( T (&x)[N] );
> ??
>>> so I implemented it using partial specialization of call_hash. (If
>>> anyone knows how to correctly implement the overload, preferably
>>> without SFINAE, let me know, although I'll spend some time looking
>>> into it if I can find the time).
>> Indeed it does! I learn something new every day. ;-)
> I'm very confused. What is "it" and what "does" it do?

"It" (overloading on pointer and array) "does" cause ambiguity.

template<class T> size_t hash_value( T * p );
template<class T, size_t N> size_t hash_value( T (&a) [N] );

int main()
    int a = { 1, 2, 3 };
    hash_value( a );

Boost list run by bdawes at, gregod at, cpdaniel at, john at