template class ugcs::vsm::Callback_forced_args

Overview

Helper class for defining custom callback creation functions which force several first arguments for the user callback. More…

#include <callback.h>

template <class Callable, class Forced_args_tuple, typename... Args>
class Callback_forced_args: public callback_internal::Callback_forced_args_helper< Callable, void, Args... >:: template Callback_ptr
{
public:
    // typedefs

    typedef callback_internal::Callback_forced_args_helper<Callable, void, Args...> Helper;
    typedef typename Helper::template Callback_ptr<Forced_args_tuple> Callback_ptr;

    // methods

    static Callback_ptr Create(
        Callable&& callable,
        Forced_args_tuple&& forced_args_tuple,
        Args&&... args
        );
};

Detailed Documentation

Helper class for defining custom callback creation functions which force several first arguments for the user callback.

Usage example:

// Enforce "int" argument with value "10".
template <class Callable, typename... Args>
typename Callback_forced_args<Callable, std::tuple<int>, Args...>::Callback_type::Ptr
Make_my_callback(Callable &&callable, Args &&... args)
{
   return Callback_forced_args<Callable, std::tuple<int>, Args...>::Create(
       std::forward<Callable>(callable), std::forward_as_tuple<int>(10),
       std::forward<Args>(args)...);
}

Parameters:

Callable

User provided callable object.

Forced_args_tuple

std::tuple for enforced arguments.

Args

User arguments for the callable. If the callable object is member function then the first user argument should be pointer (any smart pointer accepted) to the object instance.

Typedefs

typedef callback_internal::Callback_forced_args_helper<Callable, void, Args...> Helper

Helper type.

typedef typename Helper::template Callback_ptr<Forced_args_tuple> Callback_ptr

Resulted callback type.

Methods

static Callback_ptr Create(
    Callable&& callable,
    Forced_args_tuple&& forced_args_tuple,
    Args&&... args
    )

Create callback with forced first arguments.

Parameters:

callable

User provided callable object. Should be forwarded by std::forward().

forced_args_tuple

Tuple with first arguments values. Should be created by std::forward_as_tuple().

args

User provided arguments. Should be forwarded by std::forward().

Returns:

Pointer to created callback.