function closure utils finished and pass test

This commit is contained in:
Fischlurch 2009-06-21 08:38:24 +02:00
parent 2a182a2016
commit c3768b93a1
8 changed files with 388 additions and 80 deletions

View file

@ -56,7 +56,27 @@ namespace typelist{
using tuple::element;
/**
template<typename SIG>
struct _Fun
{
typedef typename FunctionSignature<function<SIG> >::Ret Ret;
typedef typename FunctionSignature<function<SIG> >::Args Args;
};
template<typename SIG>
struct _Fun<function<SIG> >
{
typedef typename FunctionSignature<function<SIG> >::Ret Ret;
typedef typename FunctionSignature<function<SIG> >::Args Args;
};
template<typename FUN>
struct is_Functor { static const bool value = false; };
template<typename SIG>
struct is_Functor<function<SIG> > { static const bool value = true; };
/**
* this Helper with repetitive specialisations for up to nine arguments
* is used either to apply a function to arguments given as a tuple, or
* to create the actual closure (functor) over all function arguments.
@ -91,14 +111,14 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f (element<1>(arg));
return f (element<0>(arg));
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg));
return std::tr1::bind (f, element<0>(arg));
}
};
@ -110,17 +130,17 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
, element<2>(arg)
);
return f ( element<0>(arg)
, element<1>(arg)
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
, element<2>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
);
}
};
@ -133,19 +153,19 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
);
}
};
@ -158,21 +178,21 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
);
}
};
@ -185,23 +205,23 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
);
}
};
@ -214,25 +234,25 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
);
}
};
@ -245,27 +265,27 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
, element<7>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
, element<7>(arg)
);
}
};
@ -278,29 +298,29 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
, element<7>(arg)
, element<8>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
, element<5>(arg)
, element<6>(arg)
, element<7>(arg)
, element<8>(arg)
);
}
};
@ -313,7 +333,8 @@ namespace typelist{
static RET
invoke (FUN& f, TUP & arg)
{
return f ( element<1>(arg)
return f ( element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
@ -321,15 +342,15 @@ namespace typelist{
, element<6>(arg)
, element<7>(arg)
, element<8>(arg)
, element<9>(arg)
);
);
}
template<typename RET, class FUN, class TUP>
static RET
bind (FUN& f, TUP & arg)
{
return std::tr1::bind (f, element<1>(arg)
return std::tr1::bind (f, element<0>(arg)
, element<1>(arg)
, element<2>(arg)
, element<3>(arg)
, element<4>(arg)
@ -337,7 +358,6 @@ namespace typelist{
, element<6>(arg)
, element<7>(arg)
, element<8>(arg)
, element<9>(arg)
);
}
};
@ -348,6 +368,7 @@ namespace typelist{
/**
* Closure-creating template.
* @note taking functor objects \em and parameters per reference
*/
template<typename SIG>
class TupleApplicator
@ -368,11 +389,11 @@ namespace typelist{
: params_(args)
{ }
BoundFunc bind (SIG& f) { return func::Apply<ARG_CNT>::template bind<BoundFunc> (f, params_); }
BoundFunc bind (function<SIG>& f) { return func::Apply<ARG_CNT>::template bind<BoundFunc> (f, params_); }
BoundFunc bind (SIG& f) { return func::Apply<ARG_CNT>::template bind<BoundFunc> (f, params_); }
BoundFunc bind (function<SIG> const& f) { return func::Apply<ARG_CNT>::template bind<BoundFunc> (f, params_); }
Ret operator() (SIG& f) { return func::Apply<ARG_CNT>::template invoke<BoundFunc> (f, params_); }
Ret operator() (function<SIG>& f) { return func::Apply<ARG_CNT>::template invoke<BoundFunc> (f, params_); }
Ret operator() (SIG& f) { return func::Apply<ARG_CNT>::template invoke<Ret> (f, params_); }
Ret operator() (function<SIG>& f) { return func::Apply<ARG_CNT>::template invoke<Ret> (f, params_); }
};
@ -386,8 +407,8 @@ namespace typelist{
template<typename SIG>
class FunctionClosure
{
typedef typename FunctionSignature< function<SIG> >::Args Args;
typedef typename FunctionSignature< function<SIG> >::Ret Ret;
typedef typename func::_Fun<SIG>::Args Args;
typedef typename func::_Fun<SIG>::Ret Ret;
function<Ret(void)> closure_;
@ -407,5 +428,64 @@ namespace typelist{
namespace func { // ...some convenience shortcuts
template<typename RET, typename ARG>
struct _Sig
{
typedef typename FunctionTypedef<RET, ARG>::Sig Type;
typedef TupleApplicator<Type> Applicator;
};
template<typename SIG, typename ARG>
struct _Clo
{
typedef typename _Fun<SIG>::Ret Ret;
typedef typename _Sig<Ret,ARG>::Type Signature;
typedef FunctionClosure<Signature> Type;
};
/** build a TupleApplicator, which embodies the given
* argument tuple and can be used to apply various
* functions to them.
*/
template<typename ARG>
typename _Sig<void, ARG>::Applicator
tupleApplicator (Tuple<ARG>& args)
{
typedef typename _Sig<void,ARG>::Type Signature;
return TupleApplicator<Signature> (args);
}
/** apply the given function to the argument tuple */
template<typename SIG, typename ARG>
typename _Fun<SIG>::Ret
apply (SIG& f, Tuple<ARG>& args)
{
typedef typename _Fun<SIG>::Ret Ret; //
typedef typename _Sig<Ret,ARG>::Type Signature; // Note: deliberately re-building the Signature Type
return TupleApplicator<Signature> (args) (f); // in order to get better error messages here
}
/** close the given function over all arguments,
* using the values from the argument tuple.
* @return a closure object, which can be
* invoked later to yield the
* function result. */
template<typename SIG, typename ARG>
typename _Clo<SIG,ARG>::Type
closure (SIG& f, Tuple<ARG>& args)
{
typedef typename _Fun<SIG>::Ret Ret;
typedef typename _Sig<Ret,ARG>::Type Signature;
typedef typename _Clo<SIG,ARG>::Type Closure;
return Closure (f,args);
}
}
}} // namespace lumiera::typelist
#endif

View file

@ -161,15 +161,15 @@ namespace typelist{
{
typedef typename Split<TYPES>::Tail Tail;
public:
typedef typename Shifted<Tail,i-1>::Types Types;
typedef typename Split<Types>::Head Head;
typedef typename Shifted<Tail,i-1>::Type Type;
typedef typename Split<Type>::Head Head;
};
template<class TYPES>
struct Shifted<TYPES,0>
{
typedef TYPES Types;
typedef typename Types::List::Head Head;
typedef TYPES Type;
typedef typename Split<Type>::Head Head;
};
@ -280,7 +280,7 @@ namespace typelist{
class ShiftedTuple
{
typedef typename Tuple::Type OurType_;
typedef typename Shifted<OurType_,i>::Types ShiftedTypes_;
typedef typename Shifted<OurType_,i>::Type ShiftedTypes_;
public:
typedef Tuple<typename ShiftedTypes_::List> Type;
};
@ -321,6 +321,11 @@ namespace typelist{
)
{ } ///< end recursion of chained ctor calls
/** shortcut: allow copy construction from a tuple
* which is rather defined by a list type */
Tuple (Tuple<NullType> const&)
{ }
template<uint> struct ShiftedTuple { typedef TupleNull Type; };
@ -330,10 +335,27 @@ namespace typelist{
/** specialisation to shift plain tuple types */
template<class TYPES, uint i>
struct Shifted<Tuple<TYPES>,i>
{
typedef typename Shifted<TYPES,i>::Type Type;
typedef typename Shifted<TYPES,i>::Head Head;
};
template<class TYPES>
struct Shifted<Tuple<TYPES>, 0>
{
typedef typename Tuple<TYPES>::Type Type;
typedef typename Tuple<TYPES>::HeadType Head;
};
namespace tuple { // some convenience access functions
template<uint n, class TUP>
typename TUP::template ShiftedTuple<n>::Type::Head&
typename Shifted<TUP,n>::Head&
element (TUP& tup)
{
return tup.template getAt<n>();

View file

@ -144,9 +144,8 @@ namespace control {
////////////////////TODO the recursion-end of the access operations goes here
protected:
string
dump (string const& prefix) const
dump (string const& prefix ="(") const
{
if (1 < prefix.length())
// remove trailing comma...

View file

@ -213,7 +213,19 @@ out: dtor ~TargetObj\(12\) successful
END
PLANNED "FunctionClosure_test" FunctionClosure_test <<END
TEST "FunctionClosure_test" FunctionClosure_test <<END
out: List1 :-<1>-<2>-<3>-
out: List2 :-<5>-<6>-<7>-
out: Args :-<5>-<9>-
out: NewArgs :-<1>-<5>-<9>-
out: :$
out: : ---Apply---
out: tup0 :...Tuple\(\)
out: tup1 :...Tuple\(11\)
out: tup2 :...Tuple\(11,12\)
out: tup3 :...Tuple\(11,12,13\)
out: :$
out: : ---Bind----
return: 0
END

View file

@ -43,7 +43,7 @@ out: TestSubMO1\(ID= [0-9]{3}\)
out: TestSubMO2\(ID= [0-9]{3}\)
out: TestSubMO21\(ID= [0-9]{3}\)
out: specialAPI()
out: pID\(\w{16}\)
out: pID\(\w{8,16}\)
END

View file

@ -22,9 +22,13 @@
/** @file function-closure-test.cpp
** Testing a combination of tr1::function objects and metaprogramming.
** Argument types will be extracted and represented as typelist, so they
** can be manipulated at compile time. This test uses some functions with
** and systematically applies or binds them to corresponding data tuples.
** Moreover, closure objects will be constructed in various flavours,
** combining a function object and a set of parameters.
**
** @todo define function-closure-test
**
** @see function-closure.hpp
** @see control::CmdClosure real world usage example
**
@ -40,14 +44,9 @@
#include "meta/dummy-functions.hpp"
#include "meta/typelist-diagnostics.hpp"
#include "meta/tuple-diagnostics.hpp"
//#include "lib/util.hpp"
//#include <boost/format.hpp>
#include <iostream>
using lib::test::showSizeof;
using lib::test::showType;
using ::test::Test;
using std::string;
using std::cout;
@ -82,6 +81,12 @@ namespace test {
return one.o_ + two.o_ + three.o_;
}
int fun0 () { return -1; }
int fun1 (int i1) { return i1; }
int fun2 (int i1, int i2) { return i1+i2; }
int fun3 (int i1, int i2, int i3) { return i1+i2+i3; }
} // (End) test data
@ -90,8 +95,8 @@ namespace test {
/*************************************************************************
* @test building a function closure for a given functor
* and arguments passed in as tuple
* @test building a function closure for a given function or functor,
* while arguments are passed in as tuple
* - accessing signatures as typelists
* - apply free function to tuple
* - apply functor to tuple
@ -151,35 +156,189 @@ namespace test {
void
check_applyFree ()
{
UNIMPLEMENTED ("verify apply free function to tuple");
cout << "\t:\n\t: ---Apply---\n";
Tuple<Types<> > tup0 ;
Tuple<Types<int> > tup1 (11);
Tuple<Types<int,int> > tup2 (11,12);
Tuple<Types<int,int,int> > tup3 (11,12,13);
DUMPVAL (tup0);
DUMPVAL (tup1);
DUMPVAL (tup2);
DUMPVAL (tup3);
ASSERT (-1 == func::Apply<0>::invoke<int> (fun0, tup0) );
ASSERT (11 == func::Apply<1>::invoke<int> (fun1, tup1) );
ASSERT (11+12 == func::Apply<2>::invoke<int> (fun2, tup2) );
ASSERT (11+12+13 == func::Apply<3>::invoke<int> (fun3, tup3) );
ASSERT (-1 == TupleApplicator<int()> (tup0) (fun0) );
ASSERT (11 == TupleApplicator<int(int)> (tup1) (fun1) );
ASSERT (11+12 == TupleApplicator<int(int,int)> (tup2) (fun2) );
ASSERT (11+12+13 == TupleApplicator<int(int,int,int)> (tup3) (fun3) );
ASSERT (-1 == func::apply(fun0, tup0) );
ASSERT (11 == func::apply(fun1, tup1) );
ASSERT (11+12 == func::apply(fun2, tup2) );
ASSERT (11+12+13 == func::apply(fun3, tup3) );
}
void
check_applyFunc ()
{
UNIMPLEMENTED ("verify apply functor to tuple");
Tuple<Types<> > tup0 ;
Tuple<Types<int> > tup1 (11);
Tuple<Types<int,int> > tup2 (11,12);
Tuple<Types<int,int,int> > tup3 (11,12,13);
function<int()> functor0 (fun0);
function<int(int)> functor1 (fun1);
function<int(int,int)> functor2 (fun2);
function<int(int,int,int)> functor3 (fun3);
ASSERT (-1 == func::Apply<0>::invoke<int> (functor0, tup0) );
ASSERT (11 == func::Apply<1>::invoke<int> (functor1, tup1) );
ASSERT (11+12 == func::Apply<2>::invoke<int> (functor2, tup2) );
ASSERT (11+12+13 == func::Apply<3>::invoke<int> (functor3, tup3) );
ASSERT (-1 == TupleApplicator<int()> (tup0) (functor0) );
ASSERT (11 == TupleApplicator<int(int)> (tup1) (functor1) );
ASSERT (11+12 == TupleApplicator<int(int,int)> (tup2) (functor2) );
ASSERT (11+12+13 == TupleApplicator<int(int,int,int)> (tup3) (functor3) );
ASSERT (-1 == func::apply(functor0, tup0) );
ASSERT (11 == func::apply(functor1, tup1) );
ASSERT (11+12 == func::apply(functor2, tup2) );
ASSERT (11+12+13 == func::apply(functor3, tup3) );
}
void
check_bindFree ()
{
UNIMPLEMENTED ("verify bind free function to tuple");
cout << "\t:\n\t: ---Bind----\n";
Tuple<Types<> > tup0 ;
Tuple<Types<int> > tup1 (11);
Tuple<Types<int,int> > tup2 (11,12);
Tuple<Types<int,int,int> > tup3 (11,12,13);
typedef function<int()> BoundFun;
BoundFun functor0 = func::Apply<0>::bind<BoundFun> (fun0, tup0);
BoundFun functor1 = func::Apply<1>::bind<BoundFun> (fun1, tup1);
BoundFun functor2 = func::Apply<2>::bind<BoundFun> (fun2, tup3);
BoundFun functor3 = func::Apply<3>::bind<BoundFun> (fun3, tup3);
ASSERT (-1 == functor0() );
ASSERT (11 == functor1() );
ASSERT (11+12 == functor2() );
ASSERT (11+12+13 == functor3() );
functor0 = TupleApplicator<int()> (tup0).bind (fun0);
functor1 = TupleApplicator<int(int)> (tup1).bind (fun1);
functor2 = TupleApplicator<int(int,int)> (tup2).bind (fun2);
functor3 = TupleApplicator<int(int,int,int)> (tup3).bind (fun3);
ASSERT (-1 == functor0() );
ASSERT (11 == functor1() );
ASSERT (11+12 == functor2() );
ASSERT (11+12+13 == functor3() );
}
void
check_bindFunc ()
{
UNIMPLEMENTED ("verify bind functor to tuple");
Tuple<Types<> > tup0 ;
Tuple<Types<int> > tup1 (11);
Tuple<Types<int,int> > tup2 (11,12);
Tuple<Types<int,int,int> > tup3 (11,12,13);
function<int()> unbound_functor0 (fun0);
function<int(int)> unbound_functor1 (fun1);
function<int(int,int)> unbound_functor2 (fun2);
function<int(int,int,int)> unbound_functor3 (fun3);
typedef function<int()> BoundFun;
BoundFun functor0 = func::Apply<0>::bind<BoundFun> (unbound_functor0, tup0);
BoundFun functor1 = func::Apply<1>::bind<BoundFun> (unbound_functor1, tup1);
BoundFun functor2 = func::Apply<2>::bind<BoundFun> (unbound_functor2, tup3);
BoundFun functor3 = func::Apply<3>::bind<BoundFun> (unbound_functor3, tup3);
ASSERT (-1 == functor0() );
ASSERT (11 == functor1() );
ASSERT (11+12 == functor2() );
ASSERT (11+12+13 == functor3() );
functor0 = TupleApplicator<int()> (tup0).bind (unbound_functor0);
functor1 = TupleApplicator<int(int)> (tup1).bind (unbound_functor1);
functor2 = TupleApplicator<int(int,int)> (tup2).bind (unbound_functor2);
functor3 = TupleApplicator<int(int,int,int)> (tup3).bind (unbound_functor3);
ASSERT (-1 == functor0() );
ASSERT (11 == functor1() );
ASSERT (11+12 == functor2() );
ASSERT (11+12+13 == functor3() );
}
void
build_closure ()
{
UNIMPLEMENTED ("build a simple tuple closure");
Tuple<Types<> > tup0 ;
Tuple<Types<int> > tup1 (11);
Tuple<Types<int,int> > tup2 (11,12);
Tuple<Types<int,int,int> > tup3 (11,12,13);
FunctionClosure<int()> clo0 (fun0,tup0);
FunctionClosure<int(int)> clo1 (fun1,tup1);
FunctionClosure<int(int,int)> clo2 (fun2,tup2);
FunctionClosure<int(int,int,int)> clo3 (fun3,tup3);
ASSERT (-1 == clo0() );
ASSERT (11 == clo1() );
ASSERT (11+12 == clo2() );
ASSERT (11+12+13 == clo3() );
function<int()> unbound_functor0 (fun0);
function<int(int)> unbound_functor1 (fun1);
function<int(int,int)> unbound_functor2 (fun2);
function<int(int,int,int)> unbound_functor3 (fun3);
clo0 = FunctionClosure<int()> (unbound_functor0,tup0);
clo1 = FunctionClosure<int(int)> (unbound_functor1,tup1);
clo2 = FunctionClosure<int(int,int)> (unbound_functor2,tup2);
clo3 = FunctionClosure<int(int,int,int)> (unbound_functor3,tup3);
ASSERT (-1 == clo0() );
ASSERT (11 == clo1() );
ASSERT (11+12 == clo2() );
ASSERT (11+12+13 == clo3() );
ASSERT (-1 == func::closure(fun0,tup0) () );
ASSERT (11 == func::closure(fun1,tup1) () );
ASSERT (11+12 == func::closure(fun2,tup2) () );
ASSERT (11+12+13 == func::closure(fun3,tup3) () );
ASSERT (-1 == func::closure(unbound_functor0,tup0) () );
ASSERT (11 == func::closure(unbound_functor1,tup1) () );
ASSERT (11+12 == func::closure(unbound_functor2,tup2) () );
ASSERT (11+12+13 == func::closure(unbound_functor3,tup3) () );
// finally combine all techniques....
typedef Tuple<List2>::Type NumberzArg;
typedef FunctionTypedef<int,NumberzArg>::Sig NumberzSig;
Tuple<NumberzArg> numberzTup (Num<5>(22), Num<6>(33), Num<7>(44));
FunctionClosure<NumberzSig> numClo (getNumberz<5,6,7>, numberzTup );
ASSERT (22+33+44 == numClo() );
}
};

View file

@ -109,7 +109,7 @@ namespace test {
TupleElementDisplayer(TUP const& tuple) : BASE(tuple) {}
string
dump (string const& prefix = "(") const
dump (string const& prefix ="(") const
{
return BASE::dump (prefix+showTupElement(element())+",");
}
@ -122,11 +122,8 @@ namespace test {
public:
TupleElementDisplayer(TUP const& tuple) : TUP(tuple) {}
protected:
string
dump (string const& prefix) const
dump (string const& prefix ="(") const
{
if (1 < prefix.length())
// removing the trailing comma

View file

@ -157,14 +157,53 @@ namespace test {
void
check_sub_tuple_types()
{
UNIMPLEMENTED ("verify head and tail type");
cout << "\t:\n\t: ---Head-and-Tail---\n";
typedef Append<Types2::List, Types1::List>::List L2;
typedef Tuple<L2> T_L2;
typedef Types<T_L2::HeadType> Head;
typedef T_L2::TailType Tail;
DISPLAY (T_L2);
DISPLAY (Head);
DISPLAY (Tail);
typedef T_L2::ThisTuple T2;
typedef Types<T2::HeadType> Head2;
typedef T2::TailType Tail2;
DISPLAY (T2);
DISPLAY (Head2);
DISPLAY (Tail2);
}
void
check_shiftedTuple()
{
UNIMPLEMENTED ("verify shifted type tuple");
cout << "\t:\n\t: ---Shifted-Tuple---\n";
typedef Append<Types2::List, Types3::List>::List L3;
typedef Tuple<L3>::Type Ty3;
typedef Tuple<Ty3> T3;
typedef Shifted<Ty3,0>::Type Ty_0; DISPLAY (Ty_0);
typedef Shifted<Ty3,1>::Type Ty_1; DISPLAY (Ty_1);
typedef Shifted<Ty3,2>::Type Ty_2; DISPLAY (Ty_2);
typedef Shifted<Ty3,3>::Type Ty_3; DISPLAY (Ty_3);
typedef Shifted<Ty3,4>::Type Ty_4; DISPLAY (Ty_4);
typedef T3::ShiftedTuple<0>::Type T_0; DISPLAY (T_0);
typedef T3::ShiftedTuple<1>::Type T_1; DISPLAY (T_1);
typedef T3::ShiftedTuple<2>::Type T_2; DISPLAY (T_2);
typedef T3::ShiftedTuple<3>::Type T_3; DISPLAY (T_3);
typedef T3::ShiftedTuple<4>::Type T_4; DISPLAY (T_4);
T3 tu3; DUMPVAL (tu3);
T_0 tu3_0 = tu3.getShifted<0>(); DUMPVAL (tu3_0);
T_1 tu3_1 = tu3.getShifted<1>(); DUMPVAL (tu3_1);
T_2 tu3_2 = tu3.getShifted<2>(); DUMPVAL (tu3_2);
T_3 tu3_3 = tu3.getShifted<3>(); DUMPVAL (tu3_3);
T_4 tu3_4 = tu3.getShifted<4>(); DUMPVAL (tu3_4);
}