std::functi...function_ref(3)
πΈ NAME πΈ
okay bestie, welcome to the std::function_ref::function_ref constructor page from the C++ Standard Libary manual, section 3 π. The header up top is std::functi...function_ref(3) (yes, the truncation is doing its little main character thing), and this whole page is literally about making a new std::function_ref.
β¨ Synopsis β¨
six overloads, all (since C++26), periodt:
template< class F > (1) (since
C++26)
function_ref( F* f ) noexcept;
template< class F > (2) (since
C++26)
function_ref( F&& f ) noexcept;
template< auto f > (3) (since
C++26)
function_ref( std::nontype_t<f> ) noexcept;
template< auto f, class U > (4) (since
C++26)
function_ref( std::nontype_t<f>, U&& obj ) noexcept;
template< auto f, class T > (5) (since
C++26)
function_ref( std::nontype_t<f>, /*cv*/ T* obj ) noexcept;
function_ref( const function_ref& other ) = default; (6) (since
C++26)
Creates a new std::function_ref. That's the whole assignment, but the overloads have opinions π
.
- (1) Initializes
bound-entitywithf, andthunk-ptrwith the address of a functionthunk. The behavior is undefined iffis a null pointer. π¨- This overload participates in overload resolution only if both
std::is_function_v<F>and/*is-invocable-using*/<F>are true.
- This overload participates in overload resolution only if both
- (2) Initializes
bound-entitywithstd::addressof(f), andthunk-ptrwith the address of a functionthunk.- Let
Tbestd::remove_reference_t<F>. This overload participates in overload resolution only if:std::remove_cvref_t<F>is not the same type asfunction_ref,std::is_member_pointer_v<T>is false, and/*is-invocable-using*/</*cv*/ T&>is true.
- Let
- (3) Initializes
bound-entitywith a pointer to an unspecified object or null pointer value, andthunk-ptrwith the address of a functionthunk.- Let
Fbedecltype(f). This overload participates in overload resolution only if/*is-invocable-using*/<F>is true. - The program is ill-formed if
f != nullptris false whenstd::is_pointer_v<F> || std::is_member_pointer_v<F>is true. π
- Let
- (4) Initializes
bound-entitywithstd::addressof(obj), andthunk-ptrwith the address of a functionthunk.- Let
Tbestd::remove_reference_t<U>andFbedecltype(f). This overload participates in overload resolution only if:std::is_rvalue_reference_v<U&&>is false, and/*is-invocable-using*/<F, /*cv*/ T&>is true.
- The program is ill-formed if
f != nullptris false whenstd::is_pointer_v<F> || std::is_member_pointer_v<F>is true.
- Let
- (5) Initializes
bound-entitywithobj, andthunk-ptrwith the address of a functionthunk. The behavior is undefined ifobjis a null pointer whenstd::is_member_pointer_v<F>is true. π¨- Let
Fbedecltype(f). This overload participates in overload resolution only if/*is-invocable-using*/<F, /*cv*/ T*>is true. - The program is ill-formed if
f != nullptris false whenstd::is_pointer_v<F> || std::is_member_pointer_v<F>is true.
- Let
- (6) Defaulted copy constructor copies the
bound-entityandthunk-ptrofother.
Now the thunk tea β: the address of a function thunk is used to initialize thunk-ptr such that a call to thunk(bound-entity, call-args...) is expression-equivalent to:
(1,3)βstd::invoke_r<R>(f, call-args...)(2)βstd::invoke_r<R>(static_cast<cv T&>(f), call-args...)(4)βstd::invoke_r<R>(f, static_cast<cv T&>(obj), call-args...)(5)βstd::invoke_r<R>(f, obj, call-args...)
/*is-invocable-using*/<T...> is true if and only if:
std::is_nothrow_invocable_r_v<R, T..., Args...>is true ifnoexis true, orstd::is_invocable_r_v<R, T..., Args...>is true
π Parameters π
otherβ anotherfunction_refto copy from.fβ a function or a Callable object to wrap.objβ an object or pointer to bound.
π Example π
This section is incomplete Reason: no example
literally no example, bestie π (the page said it, not me).
π₯ See also π₯
- constructor β constructs a new
std::move_only_functionobject(C++23)β public member function ofstd::move_only_function
π Category π
- Todo no example
and that's the whole page, bestie π«Ά. Source/version from the footer: http://cppreference.com, dated 2024.06.10, and the page is std::functi...function_ref(3). stay iconic, hydrate, and may your overload resolution always participate π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms