T
Toby Bradshaw
Hi,
Consider the following:
class A
{
public:
virtual bool foo() = 0;
};
class B : public A
{
public:
virtual bool foo() { return false; }
};
void fn()
{
std::list< A * > aList(10);
std::list< boost::shared_ptr<A> > aSharedList(10);
// This works fine..
std::count_if(
aList.begin(),
aList.end(),
boost::lambda::bind(A::foo, boost::lambda::_1)
);
// This doesn't compile..
std::count_if(
aSharedList.begin(),
aSharedList.end(),
boost::lambda::bind(A::foo, boost::lambda::_1)
);
}
--
Why doesn't the second case compile ? The only difference is that I'm
making the call through a shared_ptr instead of a naked one. If
shared_ptr semantics are (essentially) identical to the naked pointer
ones then this should surely work ? Is there some extra syntax required
in the shared_ptr case or does this simply not work ?
Thanks in advance,
Consider the following:
class A
{
public:
virtual bool foo() = 0;
};
class B : public A
{
public:
virtual bool foo() { return false; }
};
void fn()
{
std::list< A * > aList(10);
std::list< boost::shared_ptr<A> > aSharedList(10);
// This works fine..
std::count_if(
aList.begin(),
aList.end(),
boost::lambda::bind(A::foo, boost::lambda::_1)
);
// This doesn't compile..
std::count_if(
aSharedList.begin(),
aSharedList.end(),
boost::lambda::bind(A::foo, boost::lambda::_1)
);
}
--
Why doesn't the second case compile ? The only difference is that I'm
making the call through a shared_ptr instead of a naked one. If
shared_ptr semantics are (essentially) identical to the naked pointer
ones then this should surely work ? Is there some extra syntax required
in the shared_ptr case or does this simply not work ?
Thanks in advance,