Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion] is there anything resembling a joint_view of 2 maps?
From: Christopher Schmidt (mr.chr.schmidt_at_[hidden])
Date: 2009-09-20 05:55:41


The current implementation of views do not preserve the associative-ness
of the underlying sequence(s). In your specific example, the joint_view
is a plain forward sequence.

You could try my c++0x-port of Boost.Fusion. My implementation correctly
preserves the category. You can find the code in the sandbox
(https://svn.boost.org/trac/boost/browser/sandbox/SOC/2009/fusion).

-Christopher

er schrieb:
> 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