Boost logo

Boost Users :

Subject: [Boost-users] [fusion] is there anything resembling a joint_view of 2 maps?
From: er (erwann.rogard_at_[hidden])
Date: 2009-09-19 23:07:29


Hi All,

I am wondering if anyone knows of anything that resembles a joint_view
of a pair of maps.

    typedef mpl::int_<1> key1_;
    typedef mpl::int_<2> key2_;

    typedef pair<key1_,int> pair1_;
    typedef pair<key2_,int> pair2_;

     typedef map<pair1_> map1_;
     typedef map<pair2_> map2_;

     map1_ m1( make_pair<key1_>(1) );
     map2_ m2( make_pair<key2_>(2) );
     typedef joint_view<
         map1_,
         map2_
> jv_;

     // not supposed to compile (?), yet it does:
     jv_ view(m1,m2);
     // but not this:
     // at_key<key1_>(view)

     // I have no choice (?) but create a new map,
     // although view helps a bit for initializing it:
     typedef map<
         pair1_,
         pair2_
> map3_;

     map3_ m3 = fusion::as_map(view);

     int n1 = fusion::at_key<key1_>(m3);
     BOOST_ASSERT(n1 == 1);
     int n2 = fusion::at_key<key2_>(m3);
     BOOST_ASSERT(n2 == 2);


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