move_only_function< Ret(Args…) >#

Fully qualified name: omni::move_only_function< Ret(Args...) >

Defined in omni/detail/MoveOnlyFunctionImpl.h

template<typename Ret, typename ...Args>
class move_only_function<Ret(Args...)>#

A move-only function wrapper that can store and invoke callable objects.

Doesn’t require the callable to be copyable. Respects cv qualifications and noexcept. Specialization for noexcept(false).

Template Parameters:
  • Ret – The return type of the callable object.

  • Args – The argument types of the callable object.

Public Functions

move_only_function() = default#

Default constructor.

Constructs an empty move_only_function object.

inline move_only_function(std::nullptr_t) noexcept#

Constructor for nullptr.

Constructs an empty move_only_function object.

template<typename F>
inline move_only_function(F &&f)#

Constructs a move_only_function from a callable object.

Note

The callable object must not be of the same type as move_only_function.

Template Parameters:

F – The type of the callable object (must not be move_only_function)

Parameters:

f – The callable object to store.

inline move_only_function(move_only_function &&other) noexcept#

Move constructor.

Moves the contents of another move_only_function into this one.

Parameters:

other – The move_only_function object to move from.

template<typename F>
inline move_only_function &operator=(F &&f)#

Move assignment operator for F that is not identical to move_only_function.

Note

The callable object must not be of the same type as move_only_function.

Template Parameters:

F – The type of the callable object.

Parameters:

f – The callable object to store.

Returns:

move_only_function& A reference to this move_only_function object.

template<typename F, typename ...Args_>
inline explicit move_only_function(
std::in_place_type_t<F>,
Args_... args,
)#

Constructs a std::move_only_function whose target is of type std::decay_t<F> and direct-non-list-initialized with std::forward<CArgs>(args)…

Parameters:

args – Arguments for the constructor of F.

inline move_only_function &operator=(
move_only_function &&other,
) noexcept#

Move assignment operator.

Moves the contents of another move_only_function into this one.

Parameters:

other – The move_only_function object to move from.

Returns:

move_only_function& A reference to this move_only_function object.

inline move_only_function &operator=(std::nullptr_t) noexcept#

Destroys the callable if any.

Template Parameters:

std::nullptr_t

Returns:

move_only_function& A reference to this move_only_function object.

~move_only_function() = default#

Destructor.

Destroys the move_only_function object, releasing any stored resources.

inline Ret operator()(Args... args)#

Invokes the stored callable object with the provided arguments.

Respects cv and noexcept qualifications

Parameters:

args – The arguments to pass to the callable object.

Returns:

Ret The result of the callable object’s invocation.

inline explicit operator bool() const noexcept#

Checks if the move_only_function contains a callable object.

Returns:

true If the move_only_function contains a callable object.

Returns:

false If the move_only_function is empty.

Friends

inline friend bool operator==(
const move_only_function &other,
std::nullptr_t,
) noexcept#

Equality comparison with nullptr.

Checks if the move_only_function is empty (i.e., does not contain a callable object).

Parameters:

other – The move_only_function to compare.

Returns:

true If the move_only_function is empty.

Returns:

false If the move_only_function contains a callable object.

inline friend bool operator!=(
const move_only_function &other,
std::nullptr_t,
) noexcept#

Inequality comparison with nullptr.

Checks if the move_only_function is bound.

Parameters:

other – The move_only_function to compare.

Returns:

true If the move_only_function is bound.

Returns:

false If the move_only_function is unbound.