Fix instantiation of Tuple datastructs

This commit is contained in:
Fischlurch 2009-06-20 23:17:22 +02:00
parent 0117e4bce5
commit 294c254f29
3 changed files with 47 additions and 3 deletions

View file

@ -294,6 +294,33 @@ namespace typelist{
};
template<>
struct Tuple<Types<> >
: Tuple<NullType>
{
enum { SIZE = 0 };
typedef Tuple<NullType> TupleNull;
Tuple ( NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
, NullType =NullType()
)
{ } ///< end recursion of chained ctor calls
template<uint> struct ShiftedTuple { typedef TupleNull Type; };
template<uint> TupleNull& getShifted () { return static_cast<TupleNull&> (*this); }
template<uint> NullType& getAt () { return getHead(); }
};
namespace tuple { // some convenience access functions

View file

@ -190,6 +190,16 @@ namespace util {
}
/** shortcut to save some typing when having to define
* const and non-const variants of member functions
*/
template<class OBJ>
OBJ*
unConst (const OBJ* o)
{
return const_cast<OBJ*> (o);
}
/** produce an identifier based on the given string.

View file

@ -41,6 +41,7 @@
#include "lib/meta/function-closure.hpp"
#include "lib/meta/function-erasure.hpp"
#include "lib/meta/tuple.hpp"
#include "lib/util.hpp"
#include <tr1/memory>
#include <tr1/functional>
@ -59,6 +60,7 @@ namespace control {
// using lumiera::Symbol;
// using std::tr1::shared_ptr;
using util::unConst;
using std::string;
using std::ostream;
using std::tr1::function;
@ -110,7 +112,8 @@ namespace control {
class ParamAccessor
: public BASE
{
TY& element() { return BASE::template getAt<idx>(); }
TY & element() { return BASE::template getAt<idx>(); }
TY const& element() const { return unConst(this)->template getAt<idx>(); }
public:
@ -123,7 +126,7 @@ namespace control {
string
dump (string const& prefix = "(") const
{
return BASE::dump (prefix+element());
return BASE::dump (prefix+element()+",");
}
@ -145,7 +148,11 @@ namespace control {
string
dump (string const& prefix) const
{
return prefix+")";
if (1 < prefix.length())
// remove trailing comma...
return prefix.substr (0, prefix.length()-1) +")";
else
return prefix+")";
}
};