From 322c94ad33789d6eaa6a260a9028e5c5476df92f Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 23 Dec 2019 12:29:45 +0100 Subject: doc: add stream operators --- doc/src/index.rst | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/src/index.rst b/doc/src/index.rst index 3a324e1..2cb695a 100644 --- a/doc/src/index.rst +++ b/doc/src/index.rst @@ -50,7 +50,7 @@ The class template :cpp:class:`new_type` takes as a third template argument an i Derivation clauses make it possible to let the implementation derive certain operations automatically. For example, the derivation tag :cpp:var:`Arithmetic` enables automatic derivation of arithmetic operations for a given instance of :cpp:class:`new_type` (see :ref:`new-type-usage-deriving-arithmetic` below). -.. code-block:: c++ +.. code-block:: :linenos: :name: new-type-usage-deriving-arithmetic :caption: Automatically deriving arithmetic operations @@ -71,6 +71,16 @@ Synopsis { public: + // Type aliases + + using base_type = BaseType; + using tag_type = TagType; + using derivation_clause_type = decltype(DerivationClause); + + // Derivation clause access + + auto constexpr static derivation_clause = DerivationClause; + // Constructors constexpr explicit new_type() noexcept(std::is_nothrow_default_constructible_v) = /*see below*/; @@ -98,7 +108,7 @@ Synopsis auto constexpr operator->() const noexcept -> std::enable_if_t; private: - BaseType m_value; + BaseType m_value; // exposition only }; // Equality comparison operators @@ -151,4 +161,46 @@ Synopsis new_type const &) noexcept(/*see below*/) -> bool; + // Stream input/output operators + + template + auto operator<<(std::basic_ostream &&, + new_type const &) noexcept(/*see below*/) + -> std::basic_ostream &; + + template + auto operator>>(std::basic_istream &&, + new_type &&) noexcept(/*see below*/) + -> std::basic_istream &; } + +Member Type Aliases +~~~~~~~~~~~~~~~~~~~ + +Static Data Members +~~~~~~~~~~~~~~~~~~~ + +Special Member Functions +~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Equality Comparison Operators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Relational Operators +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Stream Input/Ouput Operators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Unit Tests +========== -- cgit v1.2.3