Files
cppdraft_translate/cppdraft/func/wrap/ref/class.md
2025-10-25 03:02:53 +03:00

3.2 KiB

[func.wrap.ref.class]

22 General utilities library [utilities]

22.10 Function objects [function.objects]

22.10.17 Polymorphic function wrappers [func.wrap]

22.10.17.6 Non-owning wrapper [func.wrap.ref]

22.10.17.6.2 Class template function_ref [func.wrap.ref.class]

🔗

namespace std {template<class R, class... ArgTypes>class function_ref<R(ArgTypes...) cv noexcept(noex)> {public:// [func.wrap.ref.ctor], constructors and assignment operatorstemplate function_ref(F*) noexcept; template constexpr function_ref(F&&) noexcept; template constexpr function_ref(nontype_t) noexcept; template<auto f, class U> constexpr function_ref(nontype_t, U&&) noexcept; template<auto f, class T> constexpr function_ref(nontype_t, cv T*) noexcept; constexpr function_ref(const function_ref&) noexcept = default; constexpr function_ref& operator=(const function_ref&) noexcept = default; template function_ref& operator=(T) = delete; // [func.wrap.ref.inv], invocation R operator()(ArgTypes...) const noexcept(noex); private:template<class... T>static constexpr bool is-invocable-using = see below; // exposition only R (thunk-ptr)(BoundEntityType, Args&&...) noexcept(noex); // *exposition only*BoundEntityType* bound-entity; // exposition only}; // [func.wrap.ref.deduct], deduction guidestemplate function_ref(F*) -> function_ref; template function_ref(nontype_t) -> function_ref<see below>; template<auto f, class T> function_ref(nontype_t, T&&) -> function_ref<see below>;}

1

#

An object of classfunction_ref<R(Args...) cv noexcept(noex)> stores a pointer to function thunk-ptr and an object bound-entity.

bound-entity has an unspecified trivially copyable type BoundEntityType, that models copyable and is capable of storing a pointer to object value or a pointer to function value.

The type of thunk-ptr isR(*)(BoundEntityType, Args&&...) noexcept(noex).

2

#

Each specialization of function_ref is a trivially copyable type ([basic.types.general]) that models copyable.

3

#

Within [func.wrap.ref],call-args is an argument pack with elements such thatdecltype((call-args))... denoteArgs&&... respectively.