From d5970f8ed49a15d19265c71c8618e32a9534eeee Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 3 Jan 2020 13:10:02 +0100 Subject: new_type: implement support for derivation of Hash --- doc/src/index.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'doc') diff --git a/doc/src/index.rst b/doc/src/index.rst index 07f5fc3..133ab7e 100644 --- a/doc/src/index.rst +++ b/doc/src/index.rst @@ -1,5 +1,9 @@ .. cpp:namespace-push:: nt +.. |BaseTypeDoc| replace:: The type of the contained object +.. |TagTypeDoc| replace:: A tag to uniquely identify an instance of :cpp:class:`nt::new_type` +.. |DerivationClauseDoc| replace:: A (possibly empty) list of derivation tags as generated by :cpp:func:`nt::deriving` + .. only:: html .. contents:: Table of Contents @@ -395,6 +399,26 @@ Arithmetic Operators **enablement:** This operator shall be available iff. a) :cpp:type:`new_type::base_type` is divide-assignable using the operator :literal:`/=` and b) :cpp:type:`DerivationClause` includes :cpp:var:`Arithmetic`. +:cpp:struct:`std::hash` Support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. cpp:namespace-pop:: + +.. cpp:struct:: template \ + std::hash> + + :tparam BaseType: |BaseTypeDoc| + :tparam TagType: |TagTypeDoc| + :tparam DerivationClause: |DerivationClauseDoc| + + .. cpp:function:: constexpr std::size operator()(nt::new_type const &) const + + **enablement:** This operator shall be available iff. a) :cpp:type:`nt::new_type::base_type` is hashable and b) :cpp:var:`DerivationClause` contains :cpp:var:`nt::Hash`. + + .. versionadded:: 1.0.0 + +.. cpp:namespace-push:: nt + Header :literal:`` ========================================= @@ -433,6 +457,12 @@ Standard derivation tags .. versionadded:: 1.0.0 +.. cpp:var:: auto constexpr Hash = derivable{} + + This tag enables the derivation of a specialization of :cpp:struct:`std::hash` + + .. versionadded:: 1.0.0 + .. cpp:var:: auto constexpr Indirection = derivable{} This tag enables the derivation of the "member access through pointer" operators :cpp:func:`new_type::operator->` -- cgit v1.2.3