On Sunday, February 2, 2014 9:57:50 AM UTC+8,
hbdev...@gmail.com wrote:
> Hello all,
> In functional\hash\hash.hpp in Boost ver. 1.54.0, there are many overloads of the template function hash_value where only the return type changes (see a snapshot of code at the end of this post).
> 1-
> How does the compiler determine which version of the hash_value it should use in a call?
>
> For example, for struct hash<unsigned int>::operator() it uses the version that returns boost::hash_detail::basic_numbers<T>::type.
>
> Why ? What is the rule it applies ?
You can take a look at the namespace: boost::hash_detail. A struct, enable_hash_value, is used to determine the bindings. For example, bool, char and unsigned char types are listed in basic_numbers.
> 2-
> How can I force the compiler to use a certain version of hash_value ?
You can use casting.
Feis