When you call
str.arg("123");
the best match is obtained via the function template arg
, since CString arg(const CString& argument)
requires a conversion to a user defined type. The function template then calls
return arg(CString(argument, width, base, fillChar));
but there is no CString
constructor that matches the argument list const char*, int, int, char
that you are passing here.
There can be no call to CString(uint64_t, int, int, char)
because the conversion from const char*
to uint64_t
is an invalid conversion. This simplified code sample exhibits the same problem:
#include <cstdint>
void foo(std::uint64_t) {}
int main()
{
foo("hello");
}
error: invalid conversion from 'const char*' to 'uint64_t {aka long long unsigned int}' [-fpermissive]
foo("hello");
If you were to comment out the member function template arg
, then CString arg(const CString& argument)
would be called, via the implicit conversion from const char*
to CString
.