BloombergLP::bslh::Hash_AdlWrapper

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.

Synopsis

Declared in <bslh_hash.h>

template<class HASH_ALGORITHM>
class Hash_AdlWrapper;

Description

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.

Type Aliases

NameDescription
result_type Typedef indicating the value type returned by this algorithm.

Member Functions

NameDescription
Hash_AdlWrapper [constructor]Default construct an instance of the hash algorithm wrapped in this wrapper.
computeHash Forward the call to the identical manipulator of HASH_ALGORITHM and cast the return value to 'result_type.
operator() Forward the call to the identical manipulator of HASH_ALGORITHM, passing on the specified input and numBytes.