Closed Bug 1203314 Opened 9 years ago Closed 9 years ago

Make operator<< a method on unused_t

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: mccr8, Assigned: mccr8)

Details

Attachments

(1 file)

If you include mozilla/unused.h in a file that also includes Chromium IPC logging, then operator overload resolution somehow decides that the << from unused is the right one. Making operator<< a method on unused_t rather than a free-floating function fixes this problem.
This prevents operator overload resolution from failing when this file
is included in a file that uses Chromium IPC logging.
Attachment #8659463 - Flags: review?(nfroyd)
Attachment #8659463 - Flags: review?(nfroyd) → review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/f04c038de236
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
(In reply to Andrew McCreight [:mccr8] from comment #0)
> If you include mozilla/unused.h in a file that also includes Chromium IPC
> logging, then operator overload resolution somehow decides that the << from
> unused is the right one.

Before this patch, mfbt/unused.h defined ::mozilla::operator<< and ipc/chromium/src/base/logging.h defined ::operator<<.  So, when you << to a ::mozilla::Logger&, the compiler looks in namespace ::mozilla (argument-dependent lookup), sees only definitions that don't match the provided types, and complains.

Arguably it's the IPC header that's wrong, but it's a moot point now (until the next time someone defines ::mozilla::operator<< and it comes into contact with IPC).
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: