diff --git a/doc/compat/function_ref.adoc b/doc/compat/function_ref.adoc index d8015df..9099246 100644 --- a/doc/compat/function_ref.adoc +++ b/doc/compat/function_ref.adoc @@ -18,6 +18,8 @@ The header `` implements the {cpp}26 class `function_ref` supports every combination of `const` and `noexcept` and is useful for writing higher-order functions as it can avoid a template parameter or an allocation (as `std::function` is known for). +Since `nontype_t` requires {cpp}17 as it has a template parameter of type `auto`, the constructors taking `nontype_t` are only available under {cpp}17 or later. + ## Example ```cpp @@ -50,19 +52,22 @@ struct function_ref; // cv is either `const` or empty // noex is either `true` or `false` template -class function_ref { +class function_ref +{ public: - template function_ref(F*) noexcept; - template function_ref(F&&) noexcept; - template function_ref(nontype_t) noexcept; - template function_ref(nontype_t, U&&) noexcept; - template function_ref(nontype_t, cv T*) noexcept; - function_ref(const function_ref&) noexcept = default; - function_ref& operator=(const function_ref&) noexcept = default; - template function_ref& operator=(T) = delete; + template function_ref(F*) noexcept; + template function_ref(F&&) noexcept; - R operator()(ArgTypes...) const noexcept(noex); + template function_ref(nontype_t) noexcept; + template function_ref(nontype_t, U&&) noexcept; + template function_ref(nontype_t, cv T*) noexcept; + + function_ref(const function_ref&) noexcept = default; + function_ref& operator=(const function_ref&) noexcept = default; + template function_ref& operator=(T) = delete; + + R operator()(ArgTypes...) const noexcept(noex); }; } // namespace compat @@ -95,7 +100,7 @@ template function_ref(F&& fn) noexcept; Effects:;; Constructs a `function_ref` that stores the address of the supplied Callable object `fn`. This overload only participates in resolution when `fn` is not a pointer-to-member or pointer-to-member-function. + + -Calling the `function_ref` is expression-equivalent to: + `invoke_r(static_cast(f), call-args...)`. +Calling the `function_ref` is expression-equivalent to `invoke_r(static_cast(f), call-args...)`. ### Pointer to Member Function Constructor @@ -107,7 +112,7 @@ template function_ref(nontype_t) noexcept; Effects:;; Constructs a `function_ref` using the supplied pointer to member function. This overload only participates in resolution when `f` is a pointer to member or pointer to member function. + + -Calling the `function_ref` is express-equivalent to: `invoke_r(f, class-args)`. +Calling the `function_ref` is expression-equivalent to `invoke_r(f, call-args)`. Example:;; + -- @@ -115,7 +120,7 @@ Example:;; struct point { int x = 1, y = 2; }; point p; -compat::function_ref f(compat::nontype_t<&point::x>{}); +compat::function_ref f(compat::nontype<&point::x>); BOOST_TEST_EQ(f(p), 1); ``` @@ -139,7 +144,7 @@ Example:;; struct point { int x = 1, y = 2; }; point p; -compat::function_ref f(compat::nontype_t<&point::x>{}, p); +compat::function_ref f(compat::nontype<&point::x>, p); BOOST_TEST_EQ(f(), 1); ``` @@ -161,7 +166,7 @@ Example:;; struct point { int x = 1, y = 2; }; point p; -compat::function_ref f(compat::nontype_t<&point::x>{}, &p); +compat::function_ref f(compat::nontype<&point::x>, &p); BOOST_TEST_EQ(f(), 1); ```