Empirical
Public Types | Public Member Functions | Static Public Attributes | List of all members
emp::flex_function< R(ARGS...)> Class Template Reference

#include <flex_function.h>

Public Types

using size_t = std::size_t
 
using return_t = R
 
using fun_t = std::function< R(ARGS...)>
 
using this_t = flex_function< R(ARGS...)>
 
using tuple_t = std::tuple< ARGS... >
 

Public Member Functions

template<typename T >
 flex_function (T &&fun_info)
 
 flex_function (const this_t &)=default
 
 flex_function (this_t &&)=default
 
 flex_function ()
 
this_toperator= (const this_t &)=default
 
this_toperator= (this_t &&)=default
 
this_toperator= (const fun_t &_f)
 
this_toperator= (fun_t &&_f)
 
template<typename T >
this_toperator= (T &&arg)
 
template<int ID>
void SetDefault (pack_id< ID, ARGS... > &in_default)
 Set the default value for a specific parameter. More...
 
void SetDefaults (ARGS...args)
 Set the default values for all parameters. More...
 
return_t operator() (ARGS...k) const
 Allow the function to be called with all args. More...
 
template<class... IN_ARGS>
return_t operator() (IN_ARGS &&...k) const
 All the function to be called with a subset of arguments (and the rest set to defaults) More...
 
 operator bool () const
 Determine whether this function has been set. More...
 

Static Public Attributes

static constexpr int num_args = sizeof...(ARGS)
 

Detailed Description

template<class R, class... ARGS>
class emp::flex_function< R(ARGS...)>

A functon class that is almost identical to std::function, but is provided with default values for all parameters so that it can be called with fewer arguments, as needed.

Member Typedef Documentation

template<class R , class... ARGS>
using emp::flex_function< R(ARGS...)>::fun_t = std::function<R(ARGS...)>
template<class R , class... ARGS>
using emp::flex_function< R(ARGS...)>::return_t = R
template<class R , class... ARGS>
using emp::flex_function< R(ARGS...)>::size_t = std::size_t
template<class R , class... ARGS>
using emp::flex_function< R(ARGS...)>::this_t = flex_function<R(ARGS...)>
template<class R , class... ARGS>
using emp::flex_function< R(ARGS...)>::tuple_t = std::tuple<ARGS...>

Constructor & Destructor Documentation

template<class R , class... ARGS>
template<typename T >
emp::flex_function< R(ARGS...)>::flex_function ( T &&  fun_info)
inline
template<class R , class... ARGS>
emp::flex_function< R(ARGS...)>::flex_function ( const this_t )
default
template<class R , class... ARGS>
emp::flex_function< R(ARGS...)>::flex_function ( this_t &&  )
default
template<class R , class... ARGS>
emp::flex_function< R(ARGS...)>::flex_function ( )
inline

Member Function Documentation

template<class R , class... ARGS>
emp::flex_function< R(ARGS...)>::operator bool ( ) const
inline

Determine whether this function has been set.

template<class R , class... ARGS>
return_t emp::flex_function< R(ARGS...)>::operator() ( ARGS...  k) const
inline

Allow the function to be called with all args.

template<class R , class... ARGS>
template<class... IN_ARGS>
return_t emp::flex_function< R(ARGS...)>::operator() ( IN_ARGS &&...  k) const
inline

All the function to be called with a subset of arguments (and the rest set to defaults)

template<class R , class... ARGS>
this_t& emp::flex_function< R(ARGS...)>::operator= ( const this_t )
default
template<class R , class... ARGS>
this_t& emp::flex_function< R(ARGS...)>::operator= ( this_t &&  )
default
template<class R , class... ARGS>
this_t& emp::flex_function< R(ARGS...)>::operator= ( const fun_t _f)
inline
template<class R , class... ARGS>
this_t& emp::flex_function< R(ARGS...)>::operator= ( fun_t &&  _f)
inline
template<class R , class... ARGS>
template<typename T >
this_t& emp::flex_function< R(ARGS...)>::operator= ( T &&  arg)
inline
template<class R , class... ARGS>
template<int ID>
void emp::flex_function< R(ARGS...)>::SetDefault ( pack_id< ID, ARGS... > &  in_default)
inline

Set the default value for a specific parameter.

template<class R , class... ARGS>
void emp::flex_function< R(ARGS...)>::SetDefaults ( ARGS...  args)
inline

Set the default values for all parameters.

Member Data Documentation

template<class R , class... ARGS>
constexpr int emp::flex_function< R(ARGS...)>::num_args = sizeof...(ARGS)
static

The documentation for this class was generated from the following file: