# rmp::Callback

> A function the framework keeps and calls later with arguments of types A...: what on_click(), on_drag(), on_collision() and Tilemap::on_object() store, and the type of the `on_` fields of the behaviors.

Source: https://omardev29.github.io/rmp-docs/reference/classes/rmp-Callback.html

class `#include <rmp/object.h>` [include/rmp/object.h:186](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L186-L267)

template <class... A> class Callback

A function the framework keeps and calls later with arguments of types A...: what `on_click()`, `on_drag()`, `on_collision()` and [`Tilemap::on_object()`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Tilemap.html#on_object) store, and the type of the `on_` fields of the behaviors. A lambda converts to it; it moves and does not copy.

### `Callback`

template <class F> requires(!std::is_same_v<std::decay_t<F>, Callback>) Callback(F &&fn)

function [include/rmp/object.h:209](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L209-L213)

So that a lambda can be written straight into a designated initialiser, which is the whole point of the behavior structs being aggregates.

### `set`

template <class F> void set(F &&fn)

function [include/rmp/object.h:217](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L217-L231)

Stores `fn` in place of whatever was there. A function that cannot be called with A... is a compile error that says so.

### `clear`

void clear()

function [include/rmp/object.h:234](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L234-L237)

Drops the stored function, and with it whatever it captured.

### `operator bool`

explicit operator bool() const

function [include/rmp/object.h:240](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L240)

Whether a function is stored.

### `operator()`

void operator()(A... args) const

function [include/rmp/object.h:242](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/object.h#L242-L244)

Calls the stored function with `args`; an empty Callback does nothing.
