<p><code><aclass="el"href="structboost_1_1hana_1_1pair.html"title="Generic container for two elements.">hana::pair</a></code> is conceptually the same as <code><aclass="el"href="structstd_1_1pair.html"title="Adaptation of std::pair for Hana.">std::pair</a></code>. However, <code><aclass="el"href="structboost_1_1hana_1_1pair.html"title="Generic container for two elements.">hana::pair</a></code> automatically compresses the storage of empty types, and as a result it does not have the <code>.first</code> and <code>.second</code> members. Instead, one must use the <code><aclass="el"href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4"title="Returns the first element of a pair.">hana::first</a></code> and <code><aclass="el"href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077"title="Returns the second element of a pair.">hana::second</a></code> free functions to access the elements of a pair.</p>
<dlclass="section note"><dt>Note</dt><dd>When you use a container, remember not to make assumptions about its representation, unless the documentation gives you those guarantees. More details <aclass="el"href="index.html#tutorial-containers-types">in the tutorial</a>.</dd></dl>
Two pairs <code>(x, y)</code> and ‘(x’, y')<code>are equal if and only if both </code>x == x'<code>and</code>y == y'`. <divclass="fragment"><divclass="line"><spanclass="comment">// Copyright Louis Dionne 2013-2017</span></div>
<divclass="line"><spanclass="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<divclass="line"><spanclass="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
Pairs are ordered as-if they were 2-element tuples, using a lexicographical ordering. <divclass="fragment"><divclass="line"><spanclass="comment">// Copyright Louis Dionne 2013-2017</span></div>
<divclass="line"><spanclass="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<divclass="line"><spanclass="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
Folding a pair is equivalent to folding a 2-element tuple. In other words: <divclass="fragment"><divclass="line">fold_left(<aclass="code"href="structboost_1_1hana_1_1pair.html#a1bc322b45af2148a413ba45ee8097045">make_pair</a>(x, y), s, f) == f(f(s, x), y)</div>
The model of <code>Product</code> is the simplest one possible; the first element of a pair <code>(x, y)</code> is <code>x</code>, and its second element is <code>y</code>. <divclass="fragment"><divclass="line"><spanclass="comment">// Copyright Louis Dionne 2013-2017</span></div>
<divclass="line"><spanclass="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<divclass="line"><spanclass="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<trclass="memdesc:aab78903e9982284e82744dec570afa8d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Creates a <code><aclass="el"href="structboost_1_1hana_1_1pair.html"title="Generic container for two elements.">hana::pair</a></code> with the given elements. <ahref="structboost_1_1hana_1_1pair.html#aab78903e9982284e82744dec570afa8d">More...</a><br/></td></tr>
<trclass="memdesc:a1bc322b45af2148a413ba45ee8097045"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Alias to <code>make<<aclass="el"href="structboost_1_1hana_1_1pair__tag.html"title="Tag representing hana::pair.">pair_tag</a>></code>; provided for convenience. <ahref="structboost_1_1hana_1_1pair.html#a1bc322b45af2148a413ba45ee8097045">More...</a><br/></td></tr>
<trclass="memitem:a22bef1b2c14cf393a3a9cb1924d8c8ff"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a22bef1b2c14cf393a3a9cb1924d8c8ff">operator==</a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:a22bef1b2c14cf393a3a9cb1924d8c8ff"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547"title="Returns a Logical representing whether x is equal to y.">hana::equal</a></code><br/></td></tr>
<trclass="memitem:a4ecea0deb4c00ae2eb0b0713ee0645e9"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a4ecea0deb4c00ae2eb0b0713ee0645e9">operator!=</a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:a4ecea0deb4c00ae2eb0b0713ee0645e9"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd"title="Returns a Logical representing whether x is not equal to y.">hana::not_equal</a></code><br/></td></tr>
<trclass="memitem:aca31ad50b2d35d48aac88aa762530c75"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#aca31ad50b2d35d48aac88aa762530c75">operator<</a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:aca31ad50b2d35d48aac88aa762530c75"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_orderable.html#gad510011602bdb14686f1c4ec145301c9"title="Returns a Logical representing whether x is less than y.">hana::less</a></code><br/></td></tr>
<trclass="memitem:a65b9400772e651101ae83d7f9f7ba84d"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a65b9400772e651101ae83d7f9f7ba84d">operator></a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:a65b9400772e651101ae83d7f9f7ba84d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_orderable.html#gaf9a073eafebbe514fb19dff82318f198"title="Returns a Logical representing whether x is greater than y.">hana::greater</a></code><br/></td></tr>
<trclass="memitem:a971bac762b767fe0ec222adb367c9aeb"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a971bac762b767fe0ec222adb367c9aeb">operator<=</a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:a971bac762b767fe0ec222adb367c9aeb"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_orderable.html#ga9917dd82beb67151bf5657245d37b851"title="Returns a Logical representing whether x is less than or equal to y.">hana::less_equal</a></code><br/></td></tr>
<trclass="memitem:adec95a8109b858673412671ba341611b"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr friend auto </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#adec95a8109b858673412671ba341611b">operator>=</a> (X &&x, Y &&y)</td></tr>
<trclass="memdesc:adec95a8109b858673412671ba341611b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <code><aclass="el"href="group__group-_orderable.html#ga6023631e7d0a01e16dc3fa4221fbd703"title="Returns a Logical representing whether x is greater than or equal to y.">hana::greater_equal</a></code><br/></td></tr>
<trclass="memdesc:acb8494edc410c10d824e942341f30719"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Default constructs the <code>pair</code>. Only exists when both elements of the pair are default constructible. <br/></td></tr>
<trclass="memdesc:ad258681a711a7bf24d79e9d13a7a441e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize each element of the pair with the corresponding element. Only exists when both elements of the pair are copy-constructible. <br/></td></tr>
template<typename T , typename U ></td></tr>
<trclass="memitem:aae31a284451c1c0486339c289a7887fe"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#aae31a284451c1c0486339c289a7887fe">pair</a> (T &&t, U &&u)</td></tr>
<trclass="memdesc:aae31a284451c1c0486339c289a7887fe"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize both elements of the pair by perfect-forwarding the corresponding argument. Only exists when both arguments are implicitly-convertible to the corresponding element of the pair. <br/></td></tr>
template<typename T , typename U ></td></tr>
<trclass="memitem:ad295aada872521bce6e7775795b8318e"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#ad295aada872521bce6e7775795b8318e">pair</a> (<aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>< T, U > const &other)</td></tr>
<trclass="memdesc:ad295aada872521bce6e7775795b8318e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Copy-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair. <br/></td></tr>
template<typename T , typename U ></td></tr>
<trclass="memitem:a962bff38110b5c39b1267fc88851198d"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a962bff38110b5c39b1267fc88851198d">pair</a> (<aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>< T, U >&&other)</td></tr>
<trclass="memdesc:a962bff38110b5c39b1267fc88851198d"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Move-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair. <br/></td></tr>
template<typename T , typename U ></td></tr>
<trclass="memitem:a96ada4b84949f1653de497410af50013"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr <aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>& </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a96ada4b84949f1653de497410af50013">operator=</a> (<aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>< T, U > const &other)</td></tr>
<trclass="memdesc:a96ada4b84949f1653de497410af50013"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Assign a pair to another pair. Only exists when both elements of the destination pair are assignable from the corresponding element in the source pair. <br/></td></tr>
template<typename T , typename U ></td></tr>
<trclass="memitem:a3f1a25445fa5380a78bdf524b764e1c7"><tdclass="memTemplItemLeft"align="right"valign="top">constexpr <aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>& </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="structboost_1_1hana_1_1pair.html#a3f1a25445fa5380a78bdf524b764e1c7">operator=</a> (<aclass="el"href="structboost_1_1hana_1_1pair.html">pair</a>< T, U >&&other)</td></tr>
<trclass="memdesc:a3f1a25445fa5380a78bdf524b764e1c7"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Move-assign a pair to another pair. Only exists when both elements of the destination pair are move-assignable from the corresponding element in the source pair. <br/></td></tr>
<tdclass="memname">constexpr auto <aclass="el"href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a><<aclass="el"href="structboost_1_1hana_1_1pair__tag.html">pair_tag</a>></td>
<p>Creates a <code><aclass="el"href="structboost_1_1hana_1_1pair.html"title="Generic container for two elements.">hana::pair</a></code> with the given elements. </p>
<h2><aclass="anchor"id="autotoc_md321"></a>
Example</h2>
<divclass="fragment"><divclass="line"><spanclass="comment">// Copyright Louis Dionne 2013-2017</span></div>
<divclass="line"><spanclass="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<divclass="line"><spanclass="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<tdclass="memname">constexpr auto make_pair = <aclass="el"href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a><<aclass="el"href="structboost_1_1hana_1_1pair__tag.html">pair_tag</a>></td>
<p>Alias to <code>make<<aclass="el"href="structboost_1_1hana_1_1pair__tag.html"title="Tag representing hana::pair.">pair_tag</a>></code>; provided for convenience. </p>
<h2><aclass="anchor"id="autotoc_md322"></a>
Example</h2>
<divclass="fragment"><divclass="line"><spanclass="comment">// Copyright Louis Dionne 2013-2017</span></div>
<divclass="line"><spanclass="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<divclass="line"><spanclass="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<divclass="ttc"id="agroup__group-_group_html_ga2020c526324f361a2b990fe8d1b07c20"><divclass="ttname"><ahref="group__group-_group.html#ga2020c526324f361a2b990fe8d1b07c20">boost::hana::minus</a></div><divclass="ttdeci">constexpr auto minus</div><divclass="ttdoc">Subtract two elements of a group.</div><divclass="ttdef"><b>Definition:</b> minus.hpp:51</div></div>
<divclass="ttc"id="agroup__group-_product_html_ga7bb979d59ffc3ab862cb7d9dc7730077"><divclass="ttname"><ahref="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">boost::hana::second</a></div><divclass="ttdeci">constexpr auto second</div><divclass="ttdoc">Returns the second element of a pair.</div><divclass="ttdef"><b>Definition:</b> second.hpp:32</div></div>
<divclass="ttc"id="astructboost_1_1hana_1_1pair_html_a1bc322b45af2148a413ba45ee8097045"><divclass="ttname"><ahref="structboost_1_1hana_1_1pair.html#a1bc322b45af2148a413ba45ee8097045">boost::hana::pair::make_pair</a></div><divclass="ttdeci">constexpr auto make_pair</div><divclass="ttdoc">Alias to make<pair_tag>; provided for convenience.</div><divclass="ttdef"><b>Definition:</b> pair.hpp:155</div></div>
<divclass="ttc"id="agroup__group-_monoid_html_gaeb5d4a1e967e319712f9e4791948896c"><divclass="ttname"><ahref="group__group-_monoid.html#gaeb5d4a1e967e319712f9e4791948896c">boost::hana::plus</a></div><divclass="ttdeci">constexpr auto plus</div><divclass="ttdoc">Associative binary operation on a Monoid.</div><divclass="ttdef"><b>Definition:</b> plus.hpp:47</div></div>
<divclass="ttc"id="anamespaceboost_1_1hana_html"><divclass="ttname"><ahref="namespaceboost_1_1hana.html">boost::hana</a></div><divclass="ttdoc">Namespace containing everything in the library.</div><divclass="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
<divclass="ttc"id="agroup__group-_product_html_ga34bbf4281de06dc3540441e8b2bd24f4"><divclass="ttname"><ahref="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">boost::hana::first</a></div><divclass="ttdeci">constexpr auto first</div><divclass="ttdoc">Returns the first element of a pair.</div><divclass="ttdef"><b>Definition:</b> first.hpp:33</div></div>