xentara-utils v2.0.3
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::functional::function_ref< R(ArgTypes...) const > Class Template Reference

Specialization of xentara::utils::functional::function_ref for callable with signature auto (ArgTypes...) const -> R. More...

#include <xentara/utils/functional/function_ref.hpp>

Public Member Functions

template<class F >
requires std::is_function_v<F> && std::is_invocable_r_v<R, std::remove_cvref_t<F>, ArgTypes...>
 function_ref (F *) noexcept
 Constructor that takes a function pointer.
 
template<class F >
requires (!std::same_as<std::remove_cvref_t<F>, function_ref>) && (!std::is_member_pointer_v<T>) && std::is_invocable_r_v<R, std::remove_cvref_t<F>, ArgTypes...>
constexpr function_ref (F &&) noexcept
 Constructor that takes an arbitrary callable.
 
template<auto f>
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, ArgTypes...>
constexpr function_ref (nontype_t< f >) noexcept
 Constructor that supports pointers to member functions and pointers to member objects.
 
template<auto f, class U >
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, const std::remove_reference_t<U> &, ArgTypes...> && (!std::is_rvalue_reference_v<U &&>)
constexpr function_ref (nontype_t< f >, U &&) noexcept
 Constructor that binds a callable to a reference.
 
template<auto f, class T >
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, const T &, ArgTypes...> && (!std::is_rvalue_reference_v<U &&>)
constexpr function_ref (nontype_t< f >, const T *) noexcept
 Constructor that binds a callable to a pointer.
 
template<class T >
requires (!std::same_as<T, function_ref>) && (!std::is_pointer_v<T) && (!__exposition_only_is_specialization_of<T, nontype_t>)
function_refoperator= (T)=delete
 Deleted assignment operator that restricts assignment.
 
operator() (ArgTypes...) const
 Invokes the callable.
 

Detailed Description

template<class R, class... ArgTypes>
class xentara::utils::functional::function_ref< R(ArgTypes...) const >

Specialization of xentara::utils::functional::function_ref for callable with signature auto (ArgTypes...) const -> R.

Template Parameters
RThe return type of the callable.
ArgTypesThe argument type of the callable.

Constructor & Destructor Documentation

◆ function_ref() [1/5]

template<class R , class... ArgTypes>
template<class F >
requires std::is_function_v<F> && std::is_invocable_r_v<R, std::remove_cvref_t<F>, ArgTypes...>
xentara::utils::functional::function_ref< R(ArgTypes...) const >::function_ref ( F *  )
noexcept

Constructor that takes a function pointer.

◆ function_ref() [2/5]

template<class R , class... ArgTypes>
template<class F >
requires (!std::same_as<std::remove_cvref_t<F>, function_ref>) && (!std::is_member_pointer_v<T>) && std::is_invocable_r_v<R, std::remove_cvref_t<F>, ArgTypes...>
constexpr xentara::utils::functional::function_ref< R(ArgTypes...) const >::function_ref ( F &&  )
constexprnoexcept

Constructor that takes an arbitrary callable.

Note
This constructor does not support pointers to member functions or pointers to member objects. Use function_ref(nontype_t<f>) or function_ref(nontype_t<f>, const T *) for pointers to members instead.

◆ function_ref() [3/5]

template<class R , class... ArgTypes>
template<auto f>
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, ArgTypes...>
constexpr xentara::utils::functional::function_ref< R(ArgTypes...) const >::function_ref ( nontype_t< f >  )
constexprnoexcept

Constructor that supports pointers to member functions and pointers to member objects.

◆ function_ref() [4/5]

template<class R , class... ArgTypes>
template<auto f, class U >
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, const std::remove_reference_t<U> &, ArgTypes...> && (!std::is_rvalue_reference_v<U &&>)
constexpr xentara::utils::functional::function_ref< R(ArgTypes...) const >::function_ref ( nontype_t< f >  ,
U &&   
)
constexprnoexcept

Constructor that binds a callable to a reference.

This constructor can be used to bind a pointer to member function or a pointer to member object to an object.

◆ function_ref() [5/5]

template<class R , class... ArgTypes>
template<auto f, class T >
requires std::is_invocable_r_v<R, std::remove_cvref_t<decltype(f)>, const T &, ArgTypes...> && (!std::is_rvalue_reference_v<U &&>)
constexpr xentara::utils::functional::function_ref< R(ArgTypes...) const >::function_ref ( nontype_t< f >  ,
const T *   
)
constexprnoexcept

Constructor that binds a callable to a pointer.

This constructor can be used to bind a pointer to member function or a pointer to member object to an object.

Member Function Documentation

◆ operator()()

template<class R , class... ArgTypes>
R xentara::utils::functional::function_ref< R(ArgTypes...) const >::operator() ( ArgTypes...  ) const

Invokes the callable.

◆ operator=()

template<class R , class... ArgTypes>
template<class T >
requires (!std::same_as<T, function_ref>) && (!std::is_pointer_v<T) && (!__exposition_only_is_specialization_of<T, nontype_t>)
function_ref & xentara::utils::functional::function_ref< R(ArgTypes...) const >::operator= ( )
delete

Deleted assignment operator that restricts assignment.

Assignment is only possible from:

  1. Another function_ref of the same type
  2. A function pointer
  3. Anything wrapped in xentara::utils::functional::nontype.