Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] problem when trying to access member via arg1
From: Christian Hoffmann (chrmhoffmann_at_[hidden])
Date: 2011-12-01 10:23:25


Hi,

I have below test program in which I try to call a function on each
map object. It compiles and runs fine with gcc 4.5 but not on vc10. Is
arg1 and ->* operator supposed to work when arg1 is an object and not
pointer?
Or is there another way of accessing members with arg1 (i.e. without
phoenix::bind)?

Regards,
Chris

-----------------------
#include <boost/phoenix/core.hpp>
#include <boost/phoenix/operator.hpp>

#include <iostream>
#include <vector>
#include <boost/range/algorithm.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>

struct A
{
  void f (int s) const { std::cout << "Calling f (" << s << ")...\n"; }
};

int
main (int argc, const char **argv)
{
  typedef std::map<int, boost::shared_ptr<A> > map_type;
  typedef map_type::value_type value_type;

  map_type a_map;
  a_map[3] = boost::shared_ptr<A> (new A ());

  namespace phoenix = boost::phoenix;
  using phoenix::arg_names::arg1;

  boost::for_each (a_map, ((arg1->*&value_type::second)->*&A::f) (10));
}
---------------------------


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