|
Boost Users : |
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2007-06-12 05:31:45
Yuval Ronen writes:
> Yuval Ronen wrote:
> > Aleksey Gurtovoy wrote:
> >> Yuval Ronen writes:
> >>> I have the following code:
> >>>
> >>> #include <utility>
> >>> #include <boost/mpl/map.hpp>
> >>> #include <boost/mpl/transform.hpp>
> >>>
> >>> template <typename MplPair>
> >>> struct make_ptr_pair1
> >>> {
> >>> typedef std::pair<typename MplPair::first *, typename MplPair::second *> type;
> >> ^^^
> >> mpl
> >>
> >
> > I'm really puzzled about this. Why can't I have std::pair here? The
> > whole purpose of the transform operation is to create a type-sequence of
> > std::pairs. This sequence can be used, for example, with
> > make_variant_over to create a variant of std::pairs. Can't I do that?
>
> Ah, I think I got it. When the input to mpl::transform is a mpl::map,
> then it tries to generate a mpl::map as output, and therefore the need
> for mpl::pair.
Correct.
> However, I don't need mpl::map as output, any Forward
> Sequence will suffice (as this is what make_variant_over requires). So
> is mpl::fold the answer here?
No, you can still use 'transform', like this:
typedef mpl::front_inserter< mpl::vector0<> > inserter;
typedef mpl::transform< my_map, make_ptr_pair1<mpl::_1>, inserter >::type ptr_pair_seq1;
Sorry for the late reply,
-- Aleksey Gurtovoy MetaCommunications Engineering
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