![]() |
Reference documentation for deal.II version 9.6.0
|
#include <deal.II/base/mutable_bind.h>
Public Types | |
using | TupleType |
Public Member Functions | |
template<typename FunctionType > | |
MutableBind (FunctionType function, FunctionArgs &&...arguments) | |
template<typename FunctionType > | |
MutableBind (FunctionType function, TupleType &&arguments) | |
template<typename FunctionType > | |
MutableBind (FunctionType function) | |
ReturnType | operator() () const |
void | set_arguments (TupleType &&arguments) |
void | set_arguments (FunctionArgs &&...arguments) |
void | parse_arguments (const std::string &value_string, const Patterns::PatternBase &pattern= *Patterns::Tools::Convert< TupleType >::to_pattern()) |
Private Attributes | |
const std::function< ReturnType(FunctionArgs...)> | function |
TupleType | arguments |
A mutable version of std::bind, that binds all arguments of a function pointer to a stored tuple, and allows you to update the tuple between calls.
An example usage of this class is through the helper function mutable_bind() that creates a MutableBind object on the fly, based on its arguments:
The arguments are copied to the tuple, with their reference and const attributes removed. Only copy constructible objects are allowed as function arguments. If you need to keep some references around, you may wrap your function into a lambda function:
Definition at line 80 of file mutable_bind.h.
using Utilities::MutableBind< ReturnType, FunctionArgs >::TupleType |
An alias to the stored std::tuple type. Only copy constructible objects are allowed as tuple members.
Definition at line 87 of file mutable_bind.h.
Utilities::MutableBind< ReturnType, FunctionArgs >::MutableBind | ( | FunctionType | function, |
FunctionArgs &&... | arguments ) |
Construct a MutableBind object specifying the function, and each arguments separately.
Utilities::MutableBind< ReturnType, FunctionArgs >::MutableBind | ( | FunctionType | function, |
TupleType && | arguments ) |
Construct a MutableBind object specifying the function, and the arguments as a tuple.
Utilities::MutableBind< ReturnType, FunctionArgs >::MutableBind | ( | FunctionType | function | ) |
Construct a MutableBind object specifying only the function. By default, the arguments are left to their default constructor values.
ReturnType Utilities::MutableBind< ReturnType, FunctionArgs >::operator() | ( | ) | const |
Call the original function, passing as arguments the elements of the tuple of bound arguments.
void Utilities::MutableBind< ReturnType, FunctionArgs >::set_arguments | ( | TupleType && | arguments | ) |
Set the arguments to use in function
, for next time operator()() is called, using move semantic.
void Utilities::MutableBind< ReturnType, FunctionArgs >::set_arguments | ( | FunctionArgs &&... | arguments | ) |
Set the arguments to use in function
, for next time operator()() is called, using move semantic.
void Utilities::MutableBind< ReturnType, FunctionArgs >::parse_arguments | ( | const std::string & | value_string, |
const Patterns::PatternBase & | pattern = *Patterns::Tools::Convert< TupleType >::to_pattern() ) |
Parse the arguments to use in function
from a string, for next time operator()() is called.
The conversion is performed using a user supplied Patterns::PatternBase object. By default, Patterns::Tools::Convert<TupleType>::to_pattern() is used to determine how to convert from value_string
to a TupleType object.
value_string | The string to convert from |
pattern | A unique pointer to the pattern to use when performing the conversion |
|
private |
An std::function that stores the original function.
Definition at line 154 of file mutable_bind.h.
|
private |
Currently stored arguments. These are forwarded to the function object above, when calling operator()().
Definition at line 160 of file mutable_bind.h.