1

I've been using an overload for QDebug with msvc2010 for a while:

friend QDebug &operator<<(QDebug &debug, const UsingClass &uc)
{
    debug << uc.stringForStreaming();
    return debug;
}

However, under MinGW with gcc 4.6.2 this signature is not recognized and I have to change it to (no reference &):

friend QDebug operator<<(QDebug debug, const UsingClass &uc)
{
    debug << uc.stringForStreaming();
    return debug;
}

This suprises me somehow, since I have checked the headerfile for QDebug and the signatures there are basically references.

  1. So what is the correct signature for overloading operators with QDebug? SO: How to overload operator<< for qDebug shows the one without reference, but does not tell why (different focus).
  2. Why is the first signature (&) working with msvc2010, but fails with gcc?
Community
  • 1
  • 1
Horst Walter
  • 13,663
  • 32
  • 126
  • 228

0 Answers0