|
Boost Users : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-03 14:16:59
AMDG
Igor Rubinov wrote:
> Hello,
>
> This is kind of newbie question. Any help would be greatly appreciated :).
>
> I'd like to map (SourceClass_i) list to (DestClass_i) list in the way
> that for any instance of SourceClass_i passed to the mapping
> expression, an instance of DestClass_i will be created and the result
> of the expression would be of type DestClass_i.
>
> I defined the mapping as follows:
>
> typedef mpl::map<
> mpl::pair<SourceClass1, DestClass1>,
> mpl::pair<SourceClass2, DestClass2> //, etc...
> > source2dest;
>
> Now I guess I have to take the result of mpl::at<source2dest,
> SourceClass> and apply kind of:
>
> template<typename DestClass> struct Creator
> {
> static DestClass create()
> {
> return *new DestClass;
> }
> };
>
> ...but unfortunately the things don't come together.
>
> Thank you in advance!
How do you intend to use this.
Creator<mpl::at<source2dest, SourceClass1>::type>::create()?
Can you be more specific about the problem. What you have
ought to work (Almost. create should say return DestClass(), otherwise
you have a memory leak)
In Christ,
Steven Watanabe
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