[fusion] Problems with push_back/push_front/insert into map

Consider the following program: #include <iostream> #include <boost/fusion/algorithm.hpp> #include <boost/fusion/container.hpp> #include <boost/fusion/sequence.hpp> int main() { using namespace boost::fusion; map<> m; result_of::push_back<const map<>, pair<int, int> >::type m1 = push_back(m, pair<int, int>(0)); bool b1 = has_key<int>(m1); // b1 == false bool b2 = has_key<int>(as_map(m1)); // b2 == true int sz = size(m1); // sz == 1 return 0; } According to documentation [1], result of push_back is a model of Associative Sequence if its sequence parameter implements the Associative Sequence model. Therefore, I'd expect the variable b1 to be evaluated to true, not false. Is this the intended behavior? I get the same results with push_front and insert. Tested with boost 1.43 and 1.44. [1] http://www.boost.org/doc/libs/1_44_0/libs/fusion/doc/html/fusion/algorithm/t... -- Best regards, Alexander Fokin, ru.elric@gmail.com.

Alexander Fokin schrieb:
Consider the following program:
#include <iostream> #include <boost/fusion/algorithm.hpp> #include <boost/fusion/container.hpp> #include <boost/fusion/sequence.hpp>
int main() { using namespace boost::fusion;
map<> m;
result_of::push_back<const map<>, pair<int, int> >::type m1 = push_back(m, pair<int, int>(0));
bool b1 = has_key<int>(m1); // b1 == false bool b2 = has_key<int>(as_map(m1)); // b2 == true int sz = size(m1); // sz == 1
return 0; }
According to documentation [1], result of push_back is a model of Associative Sequence if its sequence parameter implements the Associative Sequence model. Therefore, I'd expect the variable b1 to be evaluated to true, not false. Is this the intended behavior?
I get the same results with push_front and insert. Tested with boost 1.43 and 1.44.
[1] http://www.boost.org/doc/libs/1_44_0/libs/fusion/doc/html/fusion/algorithm/t...
The documentation is wrong. fusion::push_back constructs a fusion::joint_view<seq, fusion::single_view<val> const> . This joint view is only associative iff both of its underlying sequences are. The fusion::single_view is not associative, though. I think fusion::single_view should be specialized for (possibly cv-ref-qualified) fusion::pair's - and these specializations should add the associative trait. -Christopher

I've filed a trac ticket: https://svn.boost.org/trac/boost/ticket/4604 -- Best regards, Alexander Fokin, ru.elric@gmail.com.
participants (2)
-
Alexander Fokin
-
Christopher Schmidt