diff --git a/README.md b/README.md index 040a126..edd05c8 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/doc/index.rst b/doc/index.rst index e5281fd..2a146a0 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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 `__. Main features include: diff --git a/doc/ref_interface.rst b/doc/ref_interface.rst index 05c3e03..a03b323 100644 --- a/doc/ref_interface.rst +++ b/doc/ref_interface.rst @@ -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 ----------------------------- diff --git a/doc/std_function.rst b/doc/std_function.rst index c7e479d..c645b90 100644 --- a/doc/std_function.rst +++ b/doc/std_function.rst @@ -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 `, the call operator could be simplified to something like this: + +.. code-block:: c++ + + template + auto operator()(this const Wrap &self, + FArgs &&...fargs) -> decltype(iface_ptr(self)->operator()(std::forward(fargs)...)) + { + if (is_invalid(self)) { + throw std::bad_function_call{}; + } + + return iface_ptr(self)->operator()(std::forward(fargs)...); + } + Next, we take a look at the ``bool`` conversion operator: .. literalinclude:: ../tutorial/std_function.cpp