FunInfo.hpp

Wrap a function to provide more information about it.

FunInfo will collect information about a provided function and facilitate manipulations.

Developer Notes:

  • Will not currently handle return by reference!

Note

Status: ALPHA

Functions

template<typename FUN_T, typename CONVERTER_T>
static auto ChangeReturnType(FUN_T fun, CONVERTER_T convert_fun)

Change a function’s return type using a converter function.

template<typename NEW_T, typename FUN_T, typename CONVERTER_T>
static auto ChangeParameterTypes(FUN_T fun, CONVERTER_T convert_fun)

Change a function’s arguments using a simple converter function.

template<typename NEW_T, typename FUN_T, typename CONVERTER_T>
static auto ConvertParameterTypes(FUN_T fun, CONVERTER_T convert_fun)

Convert a function’s arguments using a templated lambda.

Note

: Will not work until C++20!!

template<typename NEW_T, typename FUN_T, typename R_CONVERTER_T, typename P_CONVERTER_T>
static auto ChangeTypes(FUN_T fun, R_CONVERTER_T ret_convert_fun, P_CONVERTER_T param_convert_fun)

Convert both return type AND parameter type. Convert a function’s arguments using a templated lambda.

template<size_t POS, typename FUN_T, typename BOUND_T>
auto BindAt(FUN_T fun, BOUND_T &&bound)

Lock in a specified argument of a function.

template<typename FUN_T, typename BOUND_T>
auto BindFirst(FUN_T fun, BOUND_T &&bound)

Lock in the first argument of a function.

template<size_t... IDs, typename FUN_T, typename ...Ts>
auto Bind(FUN_T fun, Ts&&... bound)

Lock in a series of specified arguments to a function.

template<typename T>
struct FunInfo
#include <FunInfo.hpp>
template<typename RETURN_T, typename ...PARAM_Ts>
struct FunInfo<RETURN_T(PARAM_Ts...)> : public FunInfo<std::function<RETURN_T(PARAM_Ts...)>>
#include <FunInfo.hpp>
template<typename RETURN_T, typename ...PARAM_Ts>
struct FunInfo<RETURN_T (*)(PARAM_Ts...)> : public FunInfo<std::function<RETURN_T(PARAM_Ts...)>>
#include <FunInfo.hpp>
template<typename CLASS_T, typename RETURN_T, typename PARAM1_T, typename ...PARAM_Ts>
struct FunInfo<RETURN_T (CLASS_T::*)(PARAM1_T, PARAM_Ts...) const>
#include <FunInfo.hpp>

Public Types

using fun_t = RETURN_T(PARAM1_T, PARAM_Ts...)
using return_t = RETURN_T
using params_t = TypePack<PARAM1_T, PARAM_Ts...>
template<size_t ID>
using arg_t = typename params_t::template get<ID>

Public Static Functions

template<typename ARG1, typename ...ARG_Ts>
static inline constexpr bool InvocableWith(ARG1&&, ARG_Ts&&...)

Test if this function can be called with a particular set of arguments.

template<typename ...ARG_Ts>
static inline constexpr bool InvocableWith()

Test if this function can be called with a particular set of argument TYPEs.

template<typename FUN_T, typename CONVERTER_T>
static inline auto ChangeReturnType(FUN_T fun, CONVERTER_T convert_fun)

Change a function’s return type using a converter function.

template<typename NEW_T, typename FUN_T, typename CONVERTER_T>
static inline auto ChangeParameterTypes(FUN_T fun, CONVERTER_T convert_fun)

Change a function’s arguments using a fixed converter function.

template<typename NEW_T, typename FUN_T, typename CONVERTER_T>
static inline auto ConvertParameterTypes(FUN_T fun, CONVERTER_T convert_lambda)

Convert a function’s arguments using a dynamic (tempalted) lambda function.

template<size_t ID, typename T>
static inline auto BindAt(CLASS_T fun, T &&bound)

Lock in a specified argument of a function.

template<size_t ID1, size_t... IDs, typename T1, typename ...Ts>
static inline auto Bind(CLASS_T fun, T1 &&bound1, Ts&&... bound)

Lock in multiple function arguments.

Public Static Attributes

static constexpr size_t num_args = 1 + sizeof...(PARAM_Ts)

Private Static Functions

template<typename BOUND_T, typename ...BEFORE_Ts, typename ...AFTER_Ts>
static inline auto BindAt_impl(CLASS_T fun, BOUND_T &&bound, TypePack<BEFORE_Ts...>, TypePack<AFTER_Ts...>)

Helper function to lock an argument at a designated position in a function.

template<typename CLASS_T, typename RETURN_T>
struct FunInfo<RETURN_T (CLASS_T::*)() const>
#include <FunInfo.hpp>

Public Types

using fun_t = RETURN_T()
using return_t = RETURN_T
using params_t = TypePack<>

Public Static Functions

template<typename ...ARG_Ts>
static inline constexpr bool InvocableWith(ARG_Ts...)

Test if this function can be called with a particular set of arguments.

template<typename FUN_T, typename CONVERTER_T>
static inline auto ChangeReturnType(FUN_T fun, CONVERTER_T convert_fun)

Change a function’s return type using a converter function.

template<typename, typename FUN_T, typename CONVERTER_T>
static inline auto ChangeParameterTypes(FUN_T fun, CONVERTER_T)

Change a function’s arguments using a converter function.

template<typename NEW_T, typename FUN_T, typename CONVERTER_T>
static inline auto ConvertParameterTypes(FUN_T fun, CONVERTER_T)

Convert a function’s arguments using a dynamic (tempalted) lambda function.

Public Static Attributes

static constexpr size_t num_args = 0