How does if(serial) work, a c++ question The Arduino documentation says if(Serial) always returns 1, except for the case where Leonardo USB serial connection delays becoming ready.  

(Leonardo has two USB IDs, and switches between them for boot loader and Serial USB.  After boot loader finishes and kicks off the program, it takes a while for the USB master (e.g. your PC) to process the disconnect of the boot loader USB device and the connection of the Serial USB device.  Thus the need for a wait.)

Now "Serial" is a static external instantiation of the Serial_ class (defined as extern Serial_ Serial;).

The c++ rules, as I understand them, do not allow a constructor to return a value, nor may the class name (which is also the constructor name) be used as a member (function) name in the class.

"Serial" cannot be defined in class Serial_, or the if(Serial) syntax would have to be if(Serial.Serial).

"Serial" cannot be defined outside the class Serial_, or it will conflict with (i.e. hide) the definition of Serial as an instantiation of Serial_.

So how does the Arduino IDE do it?

All I can think of is that the magic pre-scanner does something...  But what exactly, pray tell?
It's not the constructor that's returning the value, it's the bool operator:

Uno:

HardwareSerial::operator bool() {
    return true;
}


Leonardo:

Serial_::operator bool() {
    bool result = false;
    if (_usbLineInfo.lineState &gt; 0)
        result = true;
    delay(10);
    return result;
}


When you use the object in a setting where a boolean value is expected of it (e.g., if, while etc.) the bool() operator is called (if it exists) and that value is used.

More specifically, the bool() operator is called when the object is being cast to a bool type, either implicitly (as in if...) or explicitly (as in ... = (bool)Serial;).

More on C++ class operators here: http://en.cppreference.com/w/cpp/language/operators