Boost logo

Boost :

Subject: [boost] [fusion] Problems with push_back/push_front/insert into map
From: Alexander Fokin (apfokin_at_[hidden])
Date: 2010-08-26 19:41:39


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/transformation/functions/push_back.html

-- 
Best regards,
  Alexander Fokin, ru.elric_at_gmail.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk