BDE 4.14.0 Production release
|
#include <bslh_hash.h>
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 () |
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 bslh_hash
typedef HASH_ALGORITHM::result_type bslh::Hash_AdlWrapper< HASH_ALGORITHM >::result_type |