]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Forward declares `boost::hana::Hashable`. | |
4 | ||
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) | |
9 | */ | |
10 | ||
11 | #ifndef BOOST_HANA_FWD_CONCEPT_HASHABLE_HPP | |
12 | #define BOOST_HANA_FWD_CONCEPT_HASHABLE_HPP | |
13 | ||
14 | #include <boost/hana/config.hpp> | |
15 | ||
16 | ||
17 | BOOST_HANA_NAMESPACE_BEGIN | |
18 | //! @ingroup group-concepts | |
19 | //! @defgroup group-Hashable Hashable | |
20 | //! The `Hashable` concept represents objects that can be normalized to | |
21 | //! a type-level hash. | |
22 | //! | |
23 | //! In day to day programming, hashes are very important as a way to | |
24 | //! efficiently lookup objects in maps. While the implementation of | |
25 | //! maps is very different, the same idea of using hashes for efficient | |
26 | //! lookup applies in metaprogramming. The `Hashable` concept represents | |
27 | //! objects that can be summarized (possibly with loss of information) to | |
28 | //! a type, in a way suitable for use in hash-based data structures. Of | |
29 | //! course, in order for a hash to be well-behaved, it must obey some laws | |
30 | //! that are explained below. | |
31 | //! | |
32 | //! | |
33 | //! Minimal complete definition | |
34 | //! --------------------------- | |
35 | //! `hash`, satisfying the laws below | |
36 | //! | |
37 | //! | |
38 | //! Laws | |
39 | //! ---- | |
40 | //! First, `hana::hash` must return a `hana::type`. Furthermore, for any | |
41 | //! two `Hashable` objects `x` and `y`, it must be the case that | |
42 | //! @code | |
43 | //! x == y implies hash(x) == hash(y) | |
44 | //! @endcode | |
45 | //! | |
46 | //! where `==` denotes `hana::equal`. In other words, any two objects that | |
47 | //! compare equal (with `hana::equal`) must also have the same hash. | |
48 | //! However, the reverse is not true, and two different objects may have | |
49 | //! the same hash. This situation of two different objects having the same | |
50 | //! hash is called a _collision_. | |
51 | //! | |
52 | //! | |
53 | //! Concrete models | |
54 | //! --------------- | |
55 | //! `hana::integral_constant`, `hana::type`, `hana::string` | |
56 | //! | |
57 | //! | |
58 | //! Free model for `IntegralConstant`s | |
59 | //! ---------------------------------- | |
60 | //! Any `IntegralConstant` is `Hashable`, by normalizing its value to a | |
61 | //! `hana::integral_constant`. The type of the value held in the normalized | |
62 | //! `integral_constant` is `unsigned long long` for unsigned integral | |
63 | //! types, and `signed long long` for signed integral types. | |
64 | template <typename T> | |
65 | struct Hashable; | |
66 | BOOST_HANA_NAMESPACE_END | |
67 | ||
68 | #endif // !BOOST_HANA_FWD_CONCEPT_HASHABLE_HPP |