AIToolbox
A library that offers tools for AI problem solving.
FunctionMatching.hpp File Reference
#include <tuple>
#include <AIToolbox/TypeTraits.hpp>

Go to the source code of this file.

Classes

struct  AIToolbox::Impl::GetFunctionArguments< T >
 This struct helps decompose a function into return value and arguments. More...
 
struct  AIToolbox::Impl::GetFunctionArguments< R(*)(Args...)>
 
struct  AIToolbox::Impl::GetFunctionArguments< R(C::*)(Args...)>
 
struct  AIToolbox::Impl::GetFunctionArguments< R(C::*)(Args...) const >
 
struct  AIToolbox::Impl::IdPack< IDs >
 This class is simply a template container for ids. More...
 
struct  AIToolbox::Impl::Matcher< N, T, U, IDs >
 This struct allows to match between two tuples types. More...
 
struct  AIToolbox::Impl::Matcher< N, std::tuple<>, std::tuple< B... >, IDs... >
 
struct  AIToolbox::Impl::Matcher< N, std::tuple< F, A... >, std::tuple< F, B... >, IDs... >
 
struct  AIToolbox::Impl::Matcher< N, std::tuple< FA, A... >, std::tuple< FB, B... >, IDs... >
 
struct  AIToolbox::Impl::is_compatible_f< T, F >
 This struct reports whether a given function is compatible with a given signature. More...
 
struct  AIToolbox::Impl::is_compatible_f< R(Args...), R2(Args2...)>
 
struct  AIToolbox::Impl::is_compatible_f< R(C::*)(Args...), R2(Args2...)>
 
struct  AIToolbox::Impl::is_compatible_f< R(C::*)(Args...) const, R2(Args2...)>
 

Namespaces

 AIToolbox
 
 AIToolbox::Impl
 

Functions

Function Matcher

In this file we implement some metaprogramming goodies to improve the interface of some things.

In particular, here we implement a way to call a function which has a subset of the arguments that we actually want to pass (provided they are in the correct order). For example, say we want to call:

f(10, 0.5, 'c')

But we are passed a function

void f(char);

Then we would like to simply call

f('c');

This is useful since it allows the user to implement callbacks with only the parameters they care about, shortening interfaces a bit.

template<typename F , typename... Args, size_t... IDs>
void AIToolbox::Impl::caller (F f, std::tuple< Args... > &&args, IdPack< IDs... >)
 This function calls the input function with the subset of correct parameters from the input tuple. More...
 
template<typename C , typename F , typename... Args, size_t... IDs>
void AIToolbox::Impl::caller (C &c, F f, std::tuple< Args... > &&args, IdPack< IDs... >)
 
template<typename F , typename... Args>
void AIToolbox::Impl::callFunction (F f, Args &&...args)
 This function calls the input function with the specified arguments. More...
 
template<typename C , typename F , typename... Args>
void AIToolbox::Impl::callFunction (C &c, F f, Args &&...args)
 This function calls the input member function with the specified arguments. More...
 
Function Matcher

In this file we implement some metaprogramming goodies to improve the interface of some things.

In particular, here we implement a way to call a function which has a subset of the arguments that we actually want to pass (provided they are in the correct order). For example, say we want to call:

f(10, 0.5, 'c')

But we are passed a function

void f(char);

Then we would like to simply call

f('c');

This is useful since it allows the user to implement callbacks with only the parameters they care about, shortening interfaces a bit.

template<typename F , typename... Args, size_t... IDs>
void AIToolbox::Impl::caller (F f, std::tuple< Args... > &&args, IdPack< IDs... >)
 This function calls the input function with the subset of correct parameters from the input tuple. More...
 
template<typename C , typename F , typename... Args, size_t... IDs>
void AIToolbox::Impl::caller (C &c, F f, std::tuple< Args... > &&args, IdPack< IDs... >)
 
template<typename F , typename... Args>
void AIToolbox::Impl::callFunction (F f, Args &&...args)
 This function calls the input function with the specified arguments. More...
 
template<typename C , typename F , typename... Args>
void AIToolbox::Impl::callFunction (C &c, F f, Args &&...args)
 This function calls the input member function with the specified arguments. More...