Hi Could anyone give me a sample program to "Create an ApplyRemoveConst template that constructs a new typelist with remove_const applied to each element"
For example:
typedef TYPELIST_3(A, const B, B) TL;
typedef ApplyRemoveConst<TL>::Result TL2;
// TL2 is the same as TYPELIST_3(A, B, B)
//Typelist Definition:
template<class T, class U>
struct Typelist
{
typedef T Head;
typedef U Tail;
// Lets us a print a typelist
inline static ostream &print(ostream &os) {
return printInternal(os, "[");
}
inline static ostream &printInternal(ostream &os, string delimiter) {
os << delimiter << typeid(Head).name();
return Tail::printInternal(os, ", ");
}
private:
Typelist(); // Cannot create!
};
#define TYPELIST_1(T1) Typelist<T1, NullType>
#define TYPELIST_2(T1, T2) Typelist<T1, TYPELIST_1(T2)>
#define TYPELIST_3(T1, T2, T3) Typelist<T1, TYPELIST_2(T2, T3)>
// Null type definition
class NullType{
public:
// NullType ends a typelist (just like NULL ends a C string)
inline static ostream &printInternal(ostream &os, string delimiter) {
return os << "]";
}
};