[Solved] Crazy ambiguous thing


I think the problem is absence of const qualifier in QSharedPointer<AbstractDownloadPersistentInfo>argument. So in the first case shared pointer need to go through an extra conversion which turns to be ambiguous.

I guess this will be a simplified example. Template constructor of foo makes both variants of bar a viable overloads so ambiguity occurs even though actual attempt to construct foo<char const *> from foo<int> will lead to template instantiation failure:

template<typename T> struct
foo
{ 
    T m_v;

    foo(void) {}

    foo(foo<T> const &) {}

    template<typename X>
    foo(foo<X> const &): m_v{X{}} {}
};

void bar(foo<int const>) {}

void bar(foo<char const *>) {}

int main()
{
    foo<int> f;
    bar(f);
}

online compiler

12

solved Crazy ambiguous thing