|
Boost Users : |
From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2004-06-29 06:08:02
Hi!
The example in libs/mpl/example/tuple_from_list.cpp
and gen_linear_hierarchy from
http://aspn.activestate.com/ASPN/Mail/Message/boost/1166644
template< typename Types, typename Unit, typename Root = mpl::none >
struct gen_linear_hierarchy
{
typedef typename mpl::fold<Types,Unit,Root> ::type type; // here
};
/* usage example:
template< class Base, class T >
struct EventHander : public Base
{
virtual void OnEvent(T& obj, int eventID) = 0;
};
typedef gen_linear_hierarchy<
mpl::list<Window,Button,ScrollBar>
, EventHander<_1,_2>
> ::type v;
*/
all seem to me work fine with default constructible types.
What I need is a type generator which provides a constructor, such that
code like this one works for mpl::vectors (or other mpl::sequences)
with arbitrary length:
-------------
class C { C(std::string const & gaga) {} };
struct gen_linear_hierarchy_with_constructor
// your idea missing here
{
// and here
};
typedef
gen_linear_hierarchy_with_constructor<mpl::vector<C, C> >::type mytuple;
mytuple mt("test", "Thanks for your help");
------------------
Markus
P.S.: David and Aleksey, if you read this here: I could not find your
"coming soon" book at awprofessional.com. What's the current state
of the book I wait for so long already ...
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net