|
Boost Users : |
Subject: [Boost-users] [Q] error with shared_ptr, for_each, boost::mem_fn
From: V S P (toreason_at_[hidden])
Date: 2009-02-24 20:18:12
Hi,
I cannot resolve why boost::mem_fn does not appear to be able to resolve
to a pointer (or a reference) from a smart pointer to a derived object
(My understanding is
that get_pointer in boost::shared_ptr is specifically available so that
boost::mem_fn can work)
Here is the example of code and line with error (Visual Studion 2008 32
bit)
Thank you in advance for any help
----------------------------------------------
#include <iostream>
#include <boost/shared_ptr.hpp>
#include <boost/mem_fn.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/utility.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <vector>
using namespace boost;
using namespace std;
struct A: public enable_shared_from_this<A>
{
static void myfunc(const A* in)
{
}
};
struct B: public A,
public enable_shared_from_this<B>
{
typedef shared_ptr<B> tBptr;
};
int main (void)
{
vector<B::tBptr> v;
B::tBptr p(new B());
v.push_back(p);
p.reset(new B());
v.push_back(p);
//error cannot deduce argument
for_each (v.begin(),v.end(), boost::mem_fn(&A::myfunc));
return 0;
}
-- V S P toreason_at_[hidden] -- http://www.fastmail.fm - A fast, anti-spam email service.
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