Boost logo

Boost Users :

Subject: [Boost-users] shared_ptr and polymorphism
From: Abderrahmane Madani (abderrahmane.madani_at_[hidden])
Date: 2010-02-23 04:36:17


Just a little problem that I can't fix.
Suppose that I have these four classes

class B {};

class D1: public B {};

class D2: public B {};

class E: public D1 {};

this test:

void foo(D1 *) {}
void foo(D2 *) {}

int main()
{
E *e = new E;
foo(e);
return 0;
}
work just fine

but this one

void foo(shared_ptr<D1>) {}
void foo(shared_ptr<D2>) {}

int main()
{
shared_ptr<E> e(new E);
foo(e);
return 0;
}
the compiler say that the foo(boost::shared_ptr<E>&)' is ambiguous.

Please, can someone help me to understand why and how can I fix this problem without changing the functions name.
Thanks

Boost 1.35
GCC 4.4.1

regards



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