Resolve an ambiguous template specialization

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Resolve an ambiguous template specialization

Tom Stellard via cfe-dev
Hello all,


I have 2 methods in a C++ header.

https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qsharedpointer_impl.h?h=5.12.6#n330

https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qsharedpointer_impl.h?h=5.12.6#n370


I'm trying to compile this code:

template QSharedPointer<QTemporaryDir>::QSharedPointer(const
QSharedPointer<QTemporaryDir>&);


I get "ambiguous template specialization".

include/QtCore/qsharedpointer_impl.h:330: candidates are:
QSharedPointer<T>::QSharedPointer(const QSharedPointer<T>&) [with T =
QTemporaryDir] QSharedPointer(const QSharedPointer &other)
Q_DECL_NOTHROW : value(other.value), d(other.d)      ^~~~~~~~~~~~~~

note:                 template<class X>
QSharedPointer<T>::QSharedPointer(const QSharedPointer<X>&) [with X = X;
T = QTemporaryDir] QSharedPointer(const QSharedPointer<X> &other)
Q_DECL_NOTHROW : value(other.value), d(other.d) ^~~~~~~~~~~~~~


I have 2 questions:

1. What syntax do I need in order to make my line of code unambiguous?

2. How do I make the difference in the Clang API between the two
functions? Of course, I'm not talking about line numbers or names of
type arguments but rather the specialization info, or the fact that the
latter might be a function template etc.


Regards,

Dimitar Dobrev



_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev