On this page
  1. Callback
  2. set
  3. clear
  4. operator bool
  5. operator()

rmp::Callback

class #include <rmp/object.h> include/rmp/object.h:186
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() 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)

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)

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()

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

operator bool

explicit operator bool() const

Whether a function is stored.

operator()

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

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