typelist

How to use typelists

I read about typelists in 'Modern C++ Design' and I understood it as some kind of union for types. By putting diffrent, non-related types in a typelist, one can use it to represent more than one type at once, without inheritance. I tested typelist in some simple functions with primitive types, but I couldn't get any of them to work. Cou...

How to implement a basic Variant (& a visitor on the Variant) template in C++?

I have tried reading: http://www.boost.org/doc/libs/1_41_0/boost/variant.hpp http://www.codeproject.com/KB/cpp/TTLTyplist.aspx and chapter 3 of "Modern C++ Design" but still don't understand how variants are implemented. Can anyone paste a short example of how to define something like: class Foo { void process(Type1) { ... }; ...

how do I fix this c++ typelist template compile error?

(from reading chapter 3 of modern c++ design) typelist.hpp: class NullType {}; struct EmptyType {}; template <class T, class U> struct Typelist { typedef T Head; typedef U Tail; }; #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, T...

How to build this c++ typelist into a variant?

Here, http://stackoverflow.com/questions/2150618/how-do-i-fix-this-c-typelist-template-compile-error we built a typelist, using the code from modern c++ design. Question is now -- how do I take this and built it into a variant class? Thanks! ...

Runtime typeswitch for typelists as a switch instead of a nested if's ?

This is from TTL: //////////////////////////////////////////////////////////// // run-time type switch template <typename L, int N = 0, bool Stop=(N==length<L>::value) > struct type_switch; template <typename L, int N, bool Stop> struct type_switch { template< typename F > void operator()( size_t i, F& f ) { ...

Templating off of an arbitirary-length list of types in C++

Here's what I want to be able to type: class foo : public watchKeys<A, B, C> {}; //Or any list of keys Boost::mpl has sequences, which allow you to do this, but I don't want to have to do: class foo : public watchKeys<mpl::list<A, B, C> > {}; I don't mind it being "ugly" or verbose on the inside, but I want the way watchKeys is ult...

C++ weird syntax spotted in Boost template parameters

I was having a look at the "Function" class documentation in Boost, and stumbled across this: boost::function<float (int x, int y)> f; I must admit this syntax is highly confusing for me. How can this be legal C++ ? Is there any trick under the hood ? Is this syntax documented anywhere? ...

Typepad -Typelist inside Typelist

can we have a note typelist to include another link typelist in typepad. which has a link typelist. ...