162 lines
8.7 KiB
HTML
162 lines
8.7 KiB
HTML
<!--
|
|
Copyright Louis Dionne 2013-2017
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
-->
|
|
<!-- boost-no-inspect -->
|
|
<!-- HTML header for doxygen 1.8.9.1-->
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.20"/>
|
|
<title>Boost.Hana: Hashable</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function() { init_search(); });
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
extensions: ["tex2jax.js"],
|
|
jax: ["input/TeX","output/HTML-CSS"],
|
|
});
|
|
// Copyright Louis Dionne 2013-2017
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
MathJax.Hub.Config({
|
|
"HTML-CSS": {
|
|
linebreaks: {
|
|
automatic: true,
|
|
width: "75% container"
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
<!-- Additional javascript for drawing charts. -->
|
|
<script type="text/javascript" src="highcharts.js"></script>
|
|
<script type="text/javascript" src="highcharts-data.js"></script>
|
|
<script type="text/javascript" src="highcharts-exporting.js"></script>
|
|
<script type="text/javascript" src="chart.js"></script>
|
|
<script type="text/javascript" src="hana.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
|
|
<td style="padding-left: 0.5em;">
|
|
<div id="projectname">Boost.Hana
|
|
 <span id="projectnumber">1.7.0</span>
|
|
</div>
|
|
<div id="projectbrief">Your standard library for metaprogramming</div>
|
|
</td>
|
|
<td> <div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.svg"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.20 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(document).ready(function(){initNavTree('group__group-_hashable.html',''); initResizable(); });
|
|
/* @license-end */
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Hashable<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<p>The <code>Hashable</code> concept represents objects that can be normalized to a type-level hash. </p>
|
|
<p>In day to day programming, hashes are very important as a way to efficiently lookup objects in maps. While the implementation of maps is very different, the same idea of using hashes for efficient lookup applies in metaprogramming. The <code>Hashable</code> concept represents objects that can be summarized (possibly with loss of information) to a type, in a way suitable for use in hash-based data structures. Of course, in order for a hash to be well-behaved, it must obey some laws that are explained below.</p>
|
|
<h2><a class="anchor" id="autotoc_md117"></a>
|
|
Minimal complete definition</h2>
|
|
<p><code>hash</code>, satisfying the laws below</p>
|
|
<h2><a class="anchor" id="autotoc_md118"></a>
|
|
Laws</h2>
|
|
<p>First, <code>hana::hash</code> must return a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>. Furthermore, for any two <code>Hashable</code> objects <code>x</code> and <code>y</code>, it must be the case that </p><div class="fragment"><div class="line">x == y implies hash(x) == hash(y)</div>
|
|
</div><!-- fragment --><p>where <code>==</code> denotes <code><a class="el" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.">hana::equal</a></code>. In other words, any two objects that compare equal (with <code><a class="el" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.">hana::equal</a></code>) must also have the same hash. However, the reverse is not true, and two different objects may have the same hash. This situation of two different objects having the same hash is called a <em>collision</em>.</p>
|
|
<h2><a class="anchor" id="autotoc_md119"></a>
|
|
Concrete models</h2>
|
|
<p><code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">hana::integral_constant</a></code>, <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation.">hana::type</a></code>, <code><a class="el" href="structboost_1_1hana_1_1string.html" title="Compile-time string.">hana::string</a></code></p>
|
|
<h2><a class="anchor" id="autotoc_md120"></a>
|
|
Free model for <tt>IntegralConstant</tt>s</h2>
|
|
<p>Any <code><a class="el" href="structboost_1_1hana_1_1_integral_constant.html" title="The IntegralConstant concept represents compile-time integral values.">IntegralConstant</a></code> is <code>Hashable</code>, by normalizing its value to a <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">hana::integral_constant</a></code>. The type of the value held in the normalized <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">integral_constant</a></code> is <code>unsigned long long</code> for unsigned integral types, and <code>signed long long</code> for signed integral types. </p>
|
|
</div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!--
|
|
Copyright Louis Dionne 2013-2017
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
|
|
-->
|
|
<!-- boost-no-inspect -->
|
|
<!-- HTML footer for doxygen 1.8.9.1-->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|