1 year ago
#338873
Jackoo
How to force the compiler to use the template overload of QString arg() method?
QString
's arg()
method has many overloads. Two of them are:
QString arg(int a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const;
QString arg(Args &&... args) const;
In the following function, the compiler uses the first overload but I need the second one.
QString myformat(int num1,int num2){
return QString{"%1 %2"}.arg(num1,num2);
}
I've tried casting num1
and num2
to l/r references and that does not work. I know I can use successive arg()
or asprintf()
. But how to force the overload resolution?
c++
qstring
0 Answers
Your Answer