[func.wrap.ref.ctor]

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.3 Constructors and assignment operators [func.wrap.ref.ctor]

template<class... T> static constexpr bool is-invocable-using = see below;

If noex is true, is-invocable-using<T...> is equal to: is_nothrow_invocable_r_v<R, T..., ArgTypes...>

Otherwise, is-invocable-using<T...> is equal to: is_invocable_r_v<R, T..., ArgTypes...>

template<class F> function_ref(F* f) noexcept;

Constraints:

  • is_function_v<F> is true, and
  • is-invocable-using<F> is true.

Preconditions: f is not a null pointer.

Effects: Initializes bound-entity with f, and thunk-ptr with the address of a function thunk such that thunk(bound-entity, call-args...) is expression-equivalent ([defns.expression.equivalent]) to invoke_r<R>(f, call-args...).

template<class F> constexpr function_ref(F&& f) noexcept;

Let T be remove_reference_t<F>.

Constraints:

  • remove_cvref_t<F> is not the same type as function_ref,
  • is_member_pointer_v<T> is false, and
  • is-invocable-using<cv T&> is true.

Effects: Initializes bound-entity with addressof(f), and thunk-ptr with the address of a function thunk such that thunk(bound-entity, call-args...) is expression-equivalent ([defns.expression.equivalent]) to invoke_r<R>(static_cast<cv T&>(f), call-args...).

template<auto f> constexpr function_ref(constant_arg_t<f>) noexcept;

Constraints: is-invocable-using<const F&> is true.

Mandates: If is_pointer_v<F> || is_member_pointer_v<F> is true, then f != nullptr is true.

Effects: Initializes bound-entity with a pointer to an unspecified object or null pointer value, and thunk-ptr with the address of a function thunk such that thunk(bound-entity, call-args...) is expression-equivalent ([defns.expression.equivalent]) to invoke_r<R>(f, call-args...).

template<auto f, class U> constexpr function_ref(constant_arg_t<f>, U&& obj) noexcept;

Let T be remove_reference_t<U> and F be decltype(f).

Constraints:

  • is_rvalue_reference_v<U&&> is false, and
  • is-invocable-using<const F&, cv T&> is true.

Mandates: If is_pointer_v<F> || is_member_pointer_v<F> is true, then f != nullptr is true.

Effects: Initializes bound-entity with addressof(obj), and thunk-ptr with the address of a function thunk such that thunk(bound-entity, call-args...) is expression-equivalent ([defns.expression.equivalent]) to invoke_r<R>(f, static_cast<cv T&>(obj), call-args...).

template<auto f, class T> constexpr function_ref(constant_arg_t<f>, cv T* obj) noexcept;

Constraints: is-invocable-using<const F&, cv T*> is true.

Mandates: If is_pointer_v<F> || is_member_pointer_v<F> is true, then f != nullptr is true.

Preconditions: If is_member_pointer_v<F> is true, obj is not a null pointer.

Effects: Initializes bound-entity with obj, and thunk-ptr with the address of a function thunk such that thunk(bound-entity, call-args...) is expression-equivalent ([defns.expression.equivalent]) to invoke_r<R>(f, obj, call-args...).

template<class T> function_ref& operator=(T) = delete;

Constraints:

  • T is not the same type as function_ref,
  • is_pointer_v<T> is false, and
  • T is not a specialization of constant_arg_t.