Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions

bslh::Hash_AdlWrapper< HASH_ALGORITHM > Class Template Reference

#include <bslh_hash.h>

List of all members.

Public Types

typedef HASH_ALGORITHM::result_type result_type

Public Member Functions

 Hash_AdlWrapper ()
void operator() (const void *input, size_t numBytes)
template<class ELEMENT_TYPE >
void operator() (const ELEMENT_TYPE *input, size_t numBytes)
result_type computeHash ()

Detailed Description

template<class HASH_ALGORITHM>
class bslh::Hash_AdlWrapper< HASH_ALGORITHM >

This class is a wrapper that is useful in the case of HASH_ALGORITHM not being in the bslh namespace, which can be problematic for ADL lookup of bslh::hashAppend. Wrapping a hash algorithm in this wrapper, which is called inline, effectively forwards the algorithm into the bslh namespace.

More detailed explanation:

Normally, we define the free functions hashAppend in the same namespaces as the types they are hashing, so that ADL will find the function. In cases where this is not possible, such as std, we support defining a hashAppend overload in the bslh namespace instead. This wrapper makes sure that bslh is an associated namespace when it is used as the first argument to hashAppend, ensuring that such overloads in bslh added outside this component are still found via ADL. Without this wrapper, in the cases where the hash algorithm is neither in bslh nor in the namespace of the hashed type, ADL then fails to find the function.

This wrapper solves this problem by forcibly associating the invocation of hashAppend, wherever it may be, with the bslh namespace.

See Component bslh_hash


Member Typedef Documentation

template<class HASH_ALGORITHM >
typedef HASH_ALGORITHM::result_type bslh::Hash_AdlWrapper< HASH_ALGORITHM >::result_type

Constructor & Destructor Documentation

template<class HASH_ALGORITHM >
bslh::Hash_AdlWrapper< HASH_ALGORITHM >::Hash_AdlWrapper (  ) 

Default construct an instance of the hash algorithm wrapped in this wrapper.


Member Function Documentation

template<class HASH_ALGORITHM >
void bslh::Hash_AdlWrapper< HASH_ALGORITHM >::operator() ( const void *  input,
size_t  numBytes 
)

Forward the call to the identical manipulator of HASH_ALGORITHM, passing on the specified input and numBytes.

template<class HASH_ALGORITHM >
template<class ELEMENT_TYPE >
void bslh::Hash_AdlWrapper< HASH_ALGORITHM >::operator() ( const ELEMENT_TYPE *  input,
size_t  numBytes 
)

Forward the call to the identical manipulator of HASH_ALGORITHM, passing on the specified input and numBytes.

template<class HASH_ALGORITHM >
result_type bslh::Hash_AdlWrapper< HASH_ALGORITHM >::computeHash (  ) 

Forward the call to the identical manipulator of HASH_ALGORITHM and cast the return value to 'result_type.


The documentation for this class was generated from the following file: