Templatious
 All Classes Functions Pages
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...> Struct Template Reference

Public Types

typedef StoragePolicy< A >
::Container 
Container
 
typedef ChainFunctor
< statefulDefault, reversed,
StoragePolicy, Tl...> 
Tail
 
typedef ChainFunctor
< statefulDefault, reversed,
StoragePolicy, A, Tl...> 
ThisFctor
 
typedef std::conditional
< !reversed, detail::DoCaller,
detail::UndoCaller >::type 
CurrDoCaller
 
typedef std::conditional
< !reversed,
detail::UndoCaller,
detail::DoCaller >::type 
CurrUndoCaller
 
typedef std::conditional
< statefulDefault,
detail::StatefulProcessor
< CurrDoCaller >
, detail::FunctionalProcessor
< CurrDoCaller > >::type 
Proc
 
typedef std::conditional
< statefulDefault,
detail::StatefulReverseProcessor
< CurrUndoCaller >
, detail::FunctionalReverseProcessor
< CurrUndoCaller > >::type 
RevProc
 
typedef std::conditional
< !reversed, Proc, RevProc >
::type 
FwdProc
 
typedef std::conditional
< !reversed, RevProc, Proc >
::type 
IntBwdProc
 
typedef std::conditional
< hasUndo, IntBwdProc,
detail::UndoUnavailableProcessor >
::type 
BwdProc
 
typedef std::conditional
< hasUndo,
detail::ReverseTransform
< statefulDefault, reversed,
StoragePolicy >
, detail::DummyTransform >
::type 
RevTr
 
typedef std::conditional
< hasUndo,
detail::UndoTransform
< statefulDefault, reversed,
StoragePolicy >
, detail::DummyTransform >
::type 
UndoTr
 
typedef std::conditional
< hasUndo, detail::DoTransform
< statefulDefault, reversed,
StoragePolicy >
, detail::DummyTransform >
::type 
DoTr
 

Public Member Functions

template<class T , class... Args>
 ChainFunctor (T &&t, Args &&...args)
 
template<class... Args>
auto doFwd (Args &&...args) -> decltype(FwdProc::process(*this, std::forward< Args >(args)...))
 
template<class... Args>
auto doBwd (Args &&...args) -> decltype(BwdProc::process(*this, std::forward< Args >(args)...))
 
auto reverse () const -> decltype(std::declval< Tail >().template transform< RevTr >(std::declval< Container >().cgetRef()))
 
auto getUndo () const -> decltype(std::declval< Tail >().template transform< UndoTr >(std::declval< Container >().cgetRef()))
 
auto getDo () const -> decltype(std::declval< Tail >().template transform< DoTr >(std::declval< Container >().cgetRef()))
 
template<class... Args>
auto operator() (Args &&...args) -> decltype(this->doFwd(std::forward< Args >(args)...))
 
template<class Tr , class... Args>
auto transform (Args &&...args) const -> decltype(std::declval< Tail >().template transform< Tr >(std::forward< Args >(args)..., std::declval< Container >().cgetRef()))
 

Static Public Attributes

static const bool hasUndo = A::undo && Tail::hasUndo
 
static const bool is_last = false
 

Friends

template<class Caller >
struct detail::FunctionalProcessor
 
template<class Caller >
struct detail::FunctionalReverseProcessor
 
template<class Caller >
struct detail::StatefulProcessor
 
template<class Caller >
struct detail::StatefulReverseProcessor
 
template<class Caller >
struct detail::TailDoProcessor
 
template<class Caller >
struct detail::TailDoStatefulProcessor
 

Member Function Documentation

template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
template<class... Args>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::doBwd ( Args &&...  args) -> decltype( BwdProc::process( *this, std::forward<Args>(args)... ) )
inline

Call backward action.

Parameters
[in]argsArguments for function.

Functional example:

auto mul2 = [](int i) { return 2*i; };
auto div2 = [](int i) { return 2/i; };
auto add3 = [](int i) { return 3+i; };
auto sub3 = [](int i) { return i-3; };
auto chain = SF::chainFunctor(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
int res = chain(1);
assert( res == 5 );
int rev = chain.doBwd(res);
assert( rev == 1 );

Stateful example:

auto mul2 = [](int& i) { i*=2; };
auto div2 = [](int& i) { i/=2; };
auto add3 = [](int& i) { i+=3; };
auto sub3 = [](int& i) { i-=3; };
auto chain = SF::chainFunctor<true>(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
int res = 1;
chain(res);
assert( res == 5 );
chain.doBwd(res);
assert( res == 1 );
template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
template<class... Args>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::doFwd ( Args &&...  args) -> decltype( FwdProc::process( *this, std::forward<Args>(args)... ) )
inline

Call forward action.

Parameters
[in]argsArguments for function.

Functional example:

auto mul2 = [](int i) { return 2*i; };
auto add3 = [](int i) { return 3+i; };
auto chain = SF::chainFunctor(mul2,add3);
int res = chain(1);
assert( res == 5 );

Stateful example:

auto mul2 = [](int& i) { i*=2; };
auto add3 = [](int& i) { i+=3; };
auto chain = SF::chainFunctor<true>(mul2,add3);
int res = 1;
chain(res);
assert( res == 5 );
template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::getDo ( ) const -> decltype( std::declval<Tail>().template transform< DoTr >( std::declval<Container>().cgetRef() ) )
inline

Get do action. Functor returned does the same as () operator of this chain functor.

template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::getUndo ( ) const -> decltype( std::declval<Tail>().template transform< UndoTr >( std::declval<Container>().cgetRef() ) )
inline

Get duno functor

Functional example:

auto mul2 = [](int i) { return 2*i; };
auto div2 = [](int i) { return 2/i; };
auto add3 = [](int i) { return 3+i; };
auto sub3 = [](int i) { return i-3; };
auto chain = SF::chainFunctor(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
auto undo = chain.getUndo();
int res = chain(1);
int rev = undo(res);
assert( rev == 1 );

Stateful example:

auto mul2 = [](int& i) { i*=2; };
auto div2 = [](int& i) { i/=2; };
auto add3 = [](int& i) { i+=3; };
auto sub3 = [](int& i) { i-=3; };
auto chain = SF::chainFunctor<true>(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
auto undo = chain.getUndo();
int res = 1;
chain(res);
undo(res);
assert( res == 1 );
template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
template<class... Args>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::operator() ( Args &&...  args) -> decltype( this->doFwd( std::forward<Args>(args)... ) )
inline

Same as doFwd method.

template<bool statefulDefault, bool reversed, template< class > class StoragePolicy, class A , class... Tl>
auto templatious::ChainFunctor< statefulDefault, reversed, StoragePolicy, A, Tl...>::reverse ( ) const -> decltype( std::declval<Tail>().template transform< RevTr >( std::declval<Container>().cgetRef() ) )
inline

Reverse chain functor.

Functional example:

auto mul2 = [](int i) { return 2*i; };
auto div2 = [](int i) { return 2/i; };
auto add3 = [](int i) { return 3+i; };
auto sub3 = [](int i) { return i-3; };
auto chain = SF::chainFunctor(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
auto revChain = chain.reverse();
int res = chain(1);
int rev = revChain(res);
assert( rev == 1 );

Stateful example:

auto mul2 = [](int& i) { i*=2; };
auto div2 = [](int& i) { i/=2; };
auto add3 = [](int& i) { i+=3; };
auto sub3 = [](int& i) { i-=3; };
auto chain = SF::chainFunctor<true>(
SF::functorPair(mul2,div2),
SF::functorPair(add3,sub3)
);
auto revChain = chain.reverse();
int res = 1;
chain(res);
revChain(res);
assert( res == 1 );

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