Diana Llubpet
Diana Llubpet

Reputation: 11

Code works fine in VS 2008 but not in later versions of VS

The following code works fine in VS 2008 but in later versions it gives error (C2440: 'initializing' : cannot convert from 'overloaded-function' to 'TQStringArgFnPtr' None of the functions with this name in scope match the target type)

I am absolutely confused why. Can somebody help me what the hell differences are there between vs2008 and later v.?

#include <QtCore>

typedef QString (QString::*TQStringArgFnPtr)(const QString &, int, const QChar &) const ;
TQStringArgFnPtr QStringArgFnPtr =  &QString::arg;

Upvotes: 1

Views: 68

Answers (1)

Quentin
Quentin

Reputation: 63144

In this situation, the assignment should be enough to disambiguate the chosen function overload. It's one reason why I first thought about a compiler bug (the second one being VS).

However, a careful reading of the documentation shows that this particular overload of Qstring::arg has changed signature, from :

QString QString::arg(
    const QString & a,
    int fieldWidth = 0,
    const QChar & fillChar = QLatin1Char( ' ' )
) const

... in Qt 4.8, to :

QString QString::arg(
    const QString & a,
    int fieldWidth = 0,
    QChar fillChar = QLatin1Char( ' ' ) // no more reference !
) const

... in Qt 5.4. The first overload isn't present anymore.

Which makes me conclude that your different VS version point at different Qt versions that are incompatible in this aspect.

Upvotes: 2

Related Questions