WPILibC++ 2026.2.1
Loading...
Searching...
No Matches
slp::function_ref< R(Args...)> Class Template Reference

An implementation of std::function_ref, a lightweight non-owning reference to a callable. More...

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/util/function_ref.hpp>

Public Member Functions

constexpr function_ref () noexcept=delete
 
constexpr function_ref (const function_ref< R(Args...)> &rhs) noexcept=default
 Creates a function_ref which refers to the same callable as rhs.
 
template<typename F >
requires (!std::is_same_v<std::decay_t<F>, function_ref> && std::is_invocable_r_v<R, F &&, Args...>)
constexpr function_ref (F &&f) noexcept
 Constructs a function_ref referring to f.
 
constexpr function_ref< R(Args...)> & operator= (const function_ref< R(Args...)> &rhs) noexcept=default
 Makes *this refer to the same callable as rhs.
 
template<typename F >
requires std::is_invocable_r_v<R, F&&, Args...>
constexpr function_ref< R(Args...)> & operator= (F &&f) noexcept
 Makes *this refer to f.
 
constexpr void swap (function_ref< R(Args...)> &rhs) noexcept
 Swaps the referred callables of *this and rhs.
 
operator() (Args... args) const
 Call the stored callable with the given arguments.
 

Detailed Description

template<class R, class... Args>
class slp::function_ref< R(Args...)>

An implementation of std::function_ref, a lightweight non-owning reference to a callable.

Constructor & Destructor Documentation

◆ function_ref() [1/3]

template<class R , class... Args>
slp::function_ref< R(Args...)>::function_ref ( )
constexprdeletenoexcept

◆ function_ref() [2/3]

template<class R , class... Args>
slp::function_ref< R(Args...)>::function_ref ( const function_ref< R(Args...)> & rhs)
constexprdefaultnoexcept

Creates a function_ref which refers to the same callable as rhs.

Parameters
rhsOther function_ref.

◆ function_ref() [3/3]

template<class R , class... Args>
template<typename F >
requires (!std::is_same_v<std::decay_t<F>, function_ref> && std::is_invocable_r_v<R, F &&, Args...>)
slp::function_ref< R(Args...)>::function_ref ( F && f)
inlineconstexprnoexcept

Constructs a function_ref referring to f.

Template Parameters
FCallable type.
Parameters
fCallable to which to refer.

Member Function Documentation

◆ operator()()

template<class R , class... Args>
R slp::function_ref< R(Args...)>::operator() ( Args... args) const
inline

Call the stored callable with the given arguments.

Parameters
argsThe arguments.
Returns
The return value of the callable.

◆ operator=() [1/2]

template<class R , class... Args>
function_ref< R(Args...)> & slp::function_ref< R(Args...)>::operator= ( const function_ref< R(Args...)> & rhs)
constexprdefaultnoexcept

Makes *this refer to the same callable as rhs.

Parameters
rhsOther function_ref.
Returns
*this

◆ operator=() [2/2]

template<class R , class... Args>
template<typename F >
requires std::is_invocable_r_v<R, F&&, Args...>
function_ref< R(Args...)> & slp::function_ref< R(Args...)>::operator= ( F && f)
inlineconstexprnoexcept

Makes *this refer to f.

Parameters
fCallable to which to refer.
Returns
*this

◆ swap()

template<class R , class... Args>
void slp::function_ref< R(Args...)>::swap ( function_ref< R(Args...)> & rhs)
inlineconstexprnoexcept

Swaps the referred callables of *this and rhs.

Parameters
rhsOther function_ref.

The documentation for this class was generated from the following file: