Skip to content

Commit

Permalink
Another couple of doc bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluescarni committed May 21, 2024
1 parent 427507b commit 73f57ab
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tanuki
> classics and in the folklore and legends of various places in Japan. They are reputed to be mischievous and jolly,
> masters of disguise and shapeshifting but somewhat gullible and absent-minded.
tanuki is a small, single-header and self-contained C++20 toolkit for
tanuki is a small, single-header and self-contained C++20/23 toolkit for
[type-erasure](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Erasure).
Main features include:

Expand Down
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tanuki
classics and in the folklore and legends of various places in Japan. They are reputed to be mischievous and jolly,
masters of disguise and shapeshifting but somewhat gullible and absent-minded.

tanuki is a small, single-header and self-contained C++20 toolkit for
tanuki is a small, single-header and self-contained C++20/23 toolkit for
`type-erasure <https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Erasure>`__.
Main features include:

Expand Down
2 changes: 2 additions & 0 deletions doc/ref_interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ Second, we can use the custom configuration instance to define another wrap type
foo_iface_impl calling foo()
.. _ref_interface23:

Reference interfaces in C++23
-----------------------------

Expand Down
16 changes: 16 additions & 0 deletions doc/std_function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ the pointer to the interface via the :cpp:func:`~wrap::iface_ptr()` function, wh
the interface's call operator. The arguments are perfectly forwarded, and expression SFINAE is used
(via the trailing ``decltype(...)``) to disable the call operator if it is malformed.

Note that the visual complexity of this call operator is mainly due to CRTP limitations when employing C++20.
In :ref:`C++23 <ref_interface23>`, the call operator could be simplified to something like this:

.. code-block:: c++

template <typename Wrap, typename... FArgs>
auto operator()(this const Wrap &self,
FArgs &&...fargs) -> decltype(iface_ptr(self)->operator()(std::forward<FArgs>(fargs)...))
{
if (is_invalid(self)) {
throw std::bad_function_call{};
}

return iface_ptr(self)->operator()(std::forward<FArgs>(fargs)...);
}

Next, we take a look at the ``bool`` conversion operator:

.. literalinclude:: ../tutorial/std_function.cpp
Expand Down

0 comments on commit 73f57ab

Please sign in to comment.