std::function_ref

From cppreference.com
< cpp‎ | utility‎ | functional
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Function objects
Function wrappers
(哋它亢++11)
(哋它亢++23)
(哋它亢++26)
function_ref
(哋它亢++26)
(哋它亢++11)
(哋它亢++11)
Partial function application
(哋它亢++20)(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
(哋它亢++11)
Function invocation
(哋它亢++17)(哋它亢++23)
Identity function object
(哋它亢++20)
Reference wrappers
(哋它亢++11)
(哋它亢++11)(哋它亢++11)
(哋它亢++20)(哋它亢++20)
Transparent operator wrappers
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)  
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)
(哋它亢++14)

Negators
(哋它亢++17)
Searchers
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)    
Constrained comparators
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Old binders and adaptors
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)
(until 哋它亢++17*)  
(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)

(until 哋它亢++17*)
(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)(until 哋它亢++17*)
(until 哋它亢++20*)
(until 哋它亢++20*)
 
 
Defined in header <functional>
template< class... >
class function_ref; // not defined
(1) (since 哋它亢++26)
template< class R, class... Args >

class function_ref<R(Args...)>;
template< class R, class... Args >
class function_ref<R(Args...) noexcept>;
template< class R, class... Args >
class function_ref<R(Args...) const>;
template< class R, class... Args >

class function_ref<R(Args...) const noexcept>;
(2) (since 哋它亢++26)

Class template std::function_ref is a non-owning function wrapper. std::function_ref objects can store and invoke reference to Callable target - functions, lambda expressions, bind expressions, or other function objects, but not pointers to member functions and pointers to member objects. std::nontype can be used to construct std::function_ref by passing function pointers, pointers to member functions, and pointers to member objects.

std::function_refs supports every possible combination of cv-qualifiers, and noexcept-specifiers not including volatile provided in its template parameter.

Every specialization of std::function_ref is a TriviallyCopyable type that satisfies copyable.

Member objects

Member name Definition
bound-entity (private) an object that has an unspecified TriviallyCopyable type BoundEntityType, that satisfies copyable and is capable of storing a pointer to object value or pointer to function value
(exposition-only member object*)
thunk-ptr (private) a pointer to function of type R(*)(BoundEntityType, Args&&...) noexcept(/*noex*/) where /*noex*/ is true if noexcept is present in function signature as part of the template parameter of std::function_ref
(exposition-only member object*)

Member functions

(哋它亢++26)
constructs a new function_ref object
(public member function)
(哋它亢++26)
assigns a function_ref
(public member function)
(哋它亢++26)
invokes the stored thunk of a function_ref
(public member function)

Deduction guides

Notes

Feature-test macro Value Std Feature
__cpp_lib_function_ref 202306L (哋它亢++26) std::function_ref

Example

See also

(哋它亢++11)
wraps callable object of any copy constructible type with specified function call signature
(class template)
(哋它亢++26)
refinement of std::move_only_function that wraps callable object of any copy constructible type
(class template)
(哋它亢++23)
wraps callable object of any type with specified function call signature
(class template)
(哋它亢++26)
value construction tag
(tag)