3 Forward declares `boost::hana::hash`.
5 @copyright Louis Dionne 2016
6 @copyright Jason Rice 2016
7 Distributed under the Boost Software License, Version 1.0.
8 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_HANA_FWD_HASH_HPP
12 #define BOOST_HANA_FWD_HASH_HPP
14 #include <boost/hana/config.hpp>
15 #include <boost/hana/core/when.hpp>
18 BOOST_HANA_NAMESPACE_BEGIN
19 //! Returns a `hana::type` representing the compile-time hash of an object.
20 //! @ingroup group-Hashable
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.
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.
39 //! Given a `Hashable` `H`, the signature is
41 //! \mathtt{hash} : H \to \mathtt{type\_tag}
45 //! An object whose hash is to be computed.
50 //! @include example/hash.cpp
51 #ifdef BOOST_HANA_DOXYGEN_INVOKED
52 constexpr auto hash = [](auto const& x) {
53 return tag-dispatched;
56 template <typename T, typename = void>
57 struct hash_impl : hash_impl<T, when<true>> { };
61 constexpr auto operator()(X const& x) const;
64 constexpr hash_t hash{};
66 BOOST_HANA_NAMESPACE_END
68 #endif // !BOOST_HANA_FWD_HASH_HPP