1/*!
2@file
3Forward declares `boost::hana::hash`.
4
5Copyright Louis Dionne 2016
6Copyright Jason Rice 2016
7Distributed under the Boost Software License, Version 1.0.
8(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
9 */
10
11#ifndef BOOST_HANA_FWD_HASH_HPP
12#define BOOST_HANA_FWD_HASH_HPP
13
14#include <boost/hana/config.hpp>
15#include <boost/hana/core/when.hpp>
16
17
18namespace boost { namespace hana {
19 //! Returns a `hana::type` representing the compile-time hash of an object.
20 //! @ingroup group-Hashable
21 //!
22 //! Given an arbitrary object `x`, `hana::hash` returns a `hana::type`
23 //! representing the hash of `x`. In normal programming, hashes are
24 //! usually numerical values that can be used e.g. as indices in an
25 //! array as part of the implementation of a hash table. In the context
26 //! of metaprogramming, we are interested in type-level hashes instead.
27 //! Thus, `hana::hash` must return a `hana::type` object instead of an
28 //! integer. This `hana::type` must somehow summarize the object being
29 //! hashed, but that summary may of course lose some information.
30 //!
31 //! In order for the `hash` function to be defined properly, it must be
32 //! the case that whenever `x` is equal to `y`, then `hash(x)` is equal
33 //! to `hash(y)`. This ensures that `hana::hash` is a function in the
34 //! mathematical sense of the term.
35 //!
36 //!
37 //! Signature
38 //! ---------
39 //! Given a `Hashable` `H`, the signature is
40 //! \f$
41 //! \mathtt{hash} : H \to \mathtt{type\_tag}
42 //! \f$
43 //!
44 //! @param x
45 //! An object whose hash is to be computed.
46 //!
47 //!
48 //! Example
49 //! -------
50 //! @include example/hash.cpp
51#ifdef BOOST_HANA_DOXYGEN_INVOKED
52 constexpr auto hash = [](auto const& x) {
53 return tag-dispatched;
54 };
55#else
56 template <typename T, typename = void>
57 struct hash_impl : hash_impl<T, when<true>> { };
58
59 struct hash_t {
60 template <typename X>
61 constexpr auto operator()(X const& x) const;
62 };
63
64 BOOST_HANA_INLINE_VARIABLE constexpr hash_t hash{};
65#endif
66}} // end namespace boost::hana
67
68#endif // !BOOST_HANA_FWD_HASH_HPP
69

source code of boost/libs/hana/include/boost/hana/fwd/hash.hpp