Over on the Boost Developer group, there a lot of talk about how to best implement a typelist. Just so I can follow that discussion, could someone give me the basic thumbnail sketch of what exactly a typelist is, and what they are used for?
Hi James, A typelist is, well, a list of types :) One easy way to create a list of types is to use std::pair to create a lisp-style list. Suppose I want to create a list of three types: int, char, and std::string. typedef std::pair< int, std::pair<char, std::pair<std::string, nil> > > MyTypeList; The nil at the end is a type to mark the end of the list. I can access the first thing in the list like this: MyTypeList::first_type I can access the second thing in the list like this: MyTypeList::second_type::first_type In general, one uses recursive algorithms to manipulate these kinds of lists. You can write template metaprograms for these recursive algorithms. Horrors! :) (I do it all the time, its fun!) Cheers, Jeremy On 11/27/01 11:40 PM, "jamescurran@mvps.org" <jamescurran@mvps.org> wrote:
Over on the Boost Developer group, there a lot of talk about how to best implement a typelist. Just so I can follow that discussion, could someone give me the basic thumbnail sketch of what exactly a typelist is, and what they are used for?
Info: <http://www.boost.org> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl> Unsubscribe: <mailto:boost-users-unsubscribe@yahoogroups.com>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
-- Jeremy Siek http://www.osl.iu.edu/~jsiek Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608
James - I would just add that Andrei A. has applied type lists as an essential mechanism in the implementation of several common design patterns such as Command (Generalized Functors) and Factory. He wrote a book that covers all this: http://www.bookpool.com/.x/edk55sjw1m/ss/1?qs=modern+C%2B%2B+design HTH, Jeff
participants (3)
-
jamescurran@mvps.org
-
Jeff Garland
-
Jeremy Siek