The stream insertion (<<
) and extraction (>>
) are supposed to be non-members.
My question is basically, how can I tell when the return type of operator<< isn't going to be used by another operator<< (and so append endl)?
You cannot. Create a member function to specially append this or append an endl
once those chained calls are done with. Document your class well so that the clients know how to use it. That's your best bet.