From b196e2c10ed8823c681623dfd7bc09b0eb3ad1d2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 2 Jan 2020 22:38:18 +0100 Subject: new_type: implement support for base comparison --- doc/src/index.rst | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/src/index.rst b/doc/src/index.rst index 3ef593d..0a92d90 100644 --- a/doc/src/index.rst +++ b/doc/src/index.rst @@ -178,6 +178,30 @@ Equality Comparison Operators .. versionadded:: 1.0.0 +.. cpp:function:: template \ + constexpr bool operator==(new_type const &,\ + BaseType const &) + + **noexcept specification:** This comparison operator shall be noexcept iff. :cpp:type:`new_type::base_type` is nothrow equals-comparable. + + **enablement:** This operator shall be available iff. a) :cpp:type:`new_type::base_type` supports comparison using the operator :literal:`==` and b) the derivation clause contains :cpp:var:`EqBase` + + .. versionadded:: 1.0.0 + +.. cpp:function:: template \ + constexpr bool operator==(BaseType const &,\ + new_type const &) + + **noexcept specification:** This comparison operator shall be noexcept iff. :cpp:type:`new_type::base_type` is nothrow equals-comparable. + + **enablement:** This operator shall be available iff. a) :cpp:type:`new_type::base_type` supports comparison using the operator :literal:`==` and b) the derivation clause contains :cpp:var:`EqBase` + + .. versionadded:: 1.0.0 + .. cpp:function:: template \ @@ -190,6 +214,30 @@ Equality Comparison Operators .. versionadded:: 1.0.0 +.. cpp:function:: template \ + constexpr bool operator!=(new_type const &,\ + BaseType const &) + + **noexcept specification:** This comparison operator shall be noexcept iff. :cpp:type:`new_type::base_type` is nothrow equals-comparable. + + **enablement:** This operator shall be available iff. a) :cpp:type:`new_type::base_type` supports comparison using the operator :literal:`!=` and b) the derivation clause contains :cpp:var:`EqBase` + + .. versionadded:: 1.0.0 + +.. cpp:function:: template \ + constexpr bool operator!=(BaseType const &,\ + new_type const &) + + **noexcept specification:** This comparison operator shall be noexcept iff. :cpp:type:`new_type::base_type` is nothrow equals-comparable. + + **enablement:** This operator shall be available iff. a) :cpp:type:`new_type::base_type` supports comparison using the operator :literal:`!=` and b) the derivation clause contains :cpp:var:`EqBase` + + .. versionadded:: 1.0.0 + Relational Comparison Operators ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -355,8 +403,8 @@ This header defines the alias template :cpp:type:`derivable` as well as the set Alias template :cpp:type:`derivable` ------------------------------------ -.. cpp:type:: template \ - derivable = type +.. cpp:struct:: template \ + derivable .. versionadded:: 1.0.0 @@ -373,7 +421,7 @@ Standard derivation tags .. cpp:var:: auto constexpr EqBase = derivable{} - This tag enables the derivation of "Equality comparison with base type" operators :literal:`==` and :literal:`!=` + This tag enables the derivation of "Equality comparison with base type" operators :cpp:func:`template\ constexpr bool nt::operator==(BaseType const &, new_type const &)`, :cpp:func:`template\ constexpr bool nt::operator==(new_type const &, BaseType const &)` :cpp:func:`template\ constexpr bool nt::operator!=(BaseType const &, new_type const &)`, and :cpp:func:`template\ constexpr bool nt::operator!=(new_type const &, BaseType const &)` By virtue of its nature, deriving this feature compromises the strength of the given :cpp:class:`new_type`. .. versionadded:: 1.0.0 -- cgit v1.2.3