Boost logo

Boost :

From: Rani Sharoni (rani_sharoni_at_[hidden])
Date: 2004-01-11 09:18:49


Consider the following:
#include "boost/shared_ptr.hpp"

struct B {};
struct D : B {};

void f(boost::shared_ptr<B>); // #1
void f(boost::shared_ptr<int>); // #2

int main()
{
    boost::shared_ptr<D> dp(new D);
    f(dp); // #3 ambiguous call to overloaded function
}

#3 yield ambiguity since #1 and #2 have the same UDC rank using converting
constructor regardless of further constraints (i.e. D* is convertible to
B*).
This problem is common to classes that has generalized copy/converting
constructor and can be avoided using extra default parameter and SFINAE. I
vaguely remember that I saw this technique in the new iterator adapter.

Thanks,
Rani


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