[cfe-dev] Resolve an ambiguous template specialization
Dimitar Dobrev via cfe-dev
cfe-dev at lists.llvm.org
Mon Nov 25 05:58:35 PST 2019
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
More information about the cfe-dev
mailing list