Add a CallQueryInterface that can work with nsCOMPtr

RESOLVED FIXED

Status

()

RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

I'm tired of all the casting if I want to QI something with ambiguous nsISupports inheritance.

Comment 2

9 years ago
Comment on attachment 407554 [details] [diff] [review]
Fix

The static_cast *looks* wrong... I thought static_cast wasn't supposed to run cast operators, which is obviously what's happening here. I'd be happier with a c-style cast here: (DestinationType**) aDestination
Attachment #407554 - Flags: review?(benjamin) → review+
static_cast does do cast operators.  Testcase:

#include "stdio.h"
class A {
public:
  operator int() { return 5; }
};
int main() {
  A a;
  printf("%d\n", static_cast<int>(a));
}

prints 5 over here.  I can switch to c-style, though.
I think static_cast is better; less risk of accidentally turning into a reinterpret_cast.
Pushed http://hg.mozilla.org/mozilla-central/rev/a75d7681fa2f
Status: NEW → RESOLVED
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.