
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 ...

Markus Werle <numerical.simulation@web.de> writes:
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"); ------------------
What you really want is the fusion library (in CVS), which will replace Boost.Tuple: #include <boost/spirit/fusion/sequence/generate.hpp> typedef boost::fusion::result_of_generate<some_type_sequence>::type mytuple; I don't know of another (easy) solution for you.
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 ...
"Sanity-check reviewed" and about to enter final copyediting at Addison Wesley. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com

David Abrahams wrote:
What you really want is the fusion library (in CVS), which will replace Boost.Tuple:
#include <boost/spirit/fusion/sequence/generate.hpp>
typedef boost::fusion::result_of_generate<some_type_sequence>::type mytuple;
I don't know of another (easy) solution for you.
Sorry for being stupid, but I tried to get some compilable file out of this information and simply failed due to - as far as I can see - missing traits. Could you please provide a complete example?
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 ...
"Sanity-check reviewed" and about to enter final copyediting at Addison Wesley.
Fine. Lookin' forward to this event. Markus

Markus Werle <numerical.simulation@web.de> writes:
David Abrahams wrote:
What you really want is the fusion library (in CVS), which will replace Boost.Tuple:
#include <boost/spirit/fusion/sequence/generate.hpp>
typedef boost::fusion::result_of_generate<some_type_sequence>::type mytuple;
I don't know of another (easy) solution for you.
Sorry for being stupid, but I tried to get some compilable file out of this information and simply failed due to - as far as I can see - missing traits.
Could you please provide a complete example?
Not without fumbling about in the same way you would have to. Better ask Joel de Guzman, who wrote it.
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 ...
"Sanity-check reviewed" and about to enter final copyediting at Addison Wesley.
Fine. Lookin' forward to this event.
Markus
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com

Markus Werle wrote:
David Abrahams wrote:
What you really want is the fusion library (in CVS), which will replace Boost.Tuple:
#include <boost/spirit/fusion/sequence/generate.hpp>
typedef boost::fusion::result_of_generate<some_type_sequence>::type mytuple;
I don't know of another (easy) solution for you.
Sorry for being stupid, but I tried to get some compilable file out of this information and simply failed due to - as far as I can see - missing traits.
Could you please provide a complete example?
Please get the latest version from Spirit's CVS in branch PHOENIX_V2. The current syntax is: boost::fusion::meta::generate<T>::type given an mpl::vector, say: typedef mpl::vector<int, double, std::string> vt; you get a tuple type: boost::fusion::meta::generate<vt>::type // tuple<int, double, std::string> and you get a tuple object by: boost::fusion::generate(vt()); Pardon the confusion. I am currentlly in the process of moving the bulk of the Spirit's CVS to the boost CVS. The current stuff in the boost CVS is rather outdated and will be replaced soon. Please email me if you have further questions. Regards, -- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net

Joel de Guzman wrote:
Pardon the confusion. I am currentlly in the process of moving the bulk of the Spirit's CVS to the boost CVS. The current stuff in the boost CVS is rather outdated and will be replaced soon.
Is cvs -f -d :pserver:anonymous@cvs.sourceforge.net:2401/cvsroot/spirit checkout -r PHOENIX_V2 -P spirit OK? Markus

Hello, I have the following problem: I want to add signals to an emitting class in a generic fashion. To add a signal data member for every signal type, I inherit privately from a list of signal types. I therefore use the mpl::inherit template. class Emitter: private boost::mpl::inherit< boost::signal<void (const Emitter&, int, int)>, // emitted when size changes boost::signal<void (const Emitter&, const char*)> // emitted when name changes > { public: }; Since I want some signals to be connected automatically, I need to iterate the list of signal types. Is it possible to get a mpl::list with all the types I used within mpl::inherit? Best regards and thanks in advance, Thomas Immich

Thomas Immich <immich@ergosign.de> writes:
Hello,
I have the following problem:
I want to add signals to an emitting class in a generic fashion. To add a signal data member for every signal type, I inherit privately from a list of signal types. I therefore use the mpl::inherit template.
class Emitter: private boost::mpl::inherit< boost::signal<void (const Emitter&, int, int)>, // emitted when size changes boost::signal<void (const Emitter&, const char*)> // emitted when name changes > { public:
};
Since I want some signals to be connected automatically, I need to iterate the list of signal types. Is it possible to get a mpl::list with all the types I used within mpl::inherit?
The way to do this is to start with the type sequence, and generate the inheritance from that: typedef mpl::vector< void(Emitter const&, int,int), void(Emitter const&, char const*)
signals;
class Emitter : private mpl::fold< signals , mpl::inherit<_1,_2> , mpl::empty_base > {...}; HTH, Dave -- Dave Abrahams Boost Consulting http://www.boost-consulting.com
participants (4)
-
David Abrahams
-
Joel de Guzman
-
Markus Werle
-
Thomas Immich