diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2019-12-23 12:29:45 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2019-12-23 12:29:45 +0100 |
| commit | 322c94ad33789d6eaa6a260a9028e5c5476df92f (patch) | |
| tree | 95c2b541b08d0d5aa588b5705da24ffaa7384973 /doc | |
| parent | 6370b3fc6ffb973cc272f18d18db521c02fea0f1 (diff) | |
| download | newtype-322c94ad33789d6eaa6a260a9028e5c5476df92f.tar.xz newtype-322c94ad33789d6eaa6a260a9028e5c5476df92f.zip | |
doc: add stream operators
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/src/index.rst | 56 |
1 files changed, 54 insertions, 2 deletions
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<BaseType>) = /*see below*/; @@ -98,7 +108,7 @@ Synopsis auto constexpr operator->() const noexcept -> std::enable_if_t<DerivationClause(nt::Indirection), BaseType const *>; private: - BaseType m_value; + BaseType m_value; // exposition only }; // Equality comparison operators @@ -151,4 +161,46 @@ Synopsis new_type<BaseType, TagType, DerivationClause> const &) noexcept(/*see below*/) -> bool; + // Stream input/output operators + + template<typename BaseType, + typename TagType, + auto DerivationClause, + typename CharType, + typename StreamTraits, + typename = std::enable_if_t<DerivationClause(nt::Show)> + auto operator<<(std::basic_ostream<CharType, StreamTraits> &&, + new_type<BaseType, TagType, DerivationClause> const &) noexcept(/*see below*/) + -> std::basic_ostream<CharType, StreamTraits> &; + + template<typename BaseType, + typename TagType, + auto DerivationClause, + typename CharType, + typename StreamTraits, + typename = std::enable_if_t<DerivationClause(nt::Read)> + auto operator>>(std::basic_istream<CharType, StreamTraits> &&, + new_type<BaseType, TagType, DerivationClause> &&) noexcept(/*see below*/) + -> std::basic_istream<CharType, StreamTraits> &; } + +Member Type Aliases +~~~~~~~~~~~~~~~~~~~ + +Static Data Members +~~~~~~~~~~~~~~~~~~~ + +Special Member Functions +~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Equality Comparison Operators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Relational Operators +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Free Stream Input/Ouput Operators +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Unit Tests +========== |
