Index: mojo/public/cpp/bindings/interface_ptr.h |
diff --git a/mojo/public/cpp/bindings/interface_ptr.h b/mojo/public/cpp/bindings/interface_ptr.h |
index b868a0a5c36167c1885c16f597a600bfed4ecef2..80c09c7227effc2fb36a6049361703a4a27eb503 100644 |
--- a/mojo/public/cpp/bindings/interface_ptr.h |
+++ b/mojo/public/cpp/bindings/interface_ptr.h |
@@ -104,6 +104,16 @@ class InterfacePtr { |
return &internal_state_; |
} |
+ // Allow InterfacePtr<> to be used in boolean expressions, but not |
yzshen1
2014/07/18 19:17:43
One thing that may worth considering:
I just lande
Elliot Glaysher
2014/07/18 19:32:15
What do you propose replacing get() with?
yzshen1
2014/07/18 19:38:45
Maybe an IsBound() method on the internal state, w
|
+ // implicitly convertible to a real bool (which is dangerous). |
+ private: |
+ typedef internal::InterfacePtrState<Interface> InterfacePtr::*Testable; |
+ |
+ public: |
+ operator Testable() const { |
+ return get() ? &InterfacePtr::internal_state_ : NULL; |
+ } |
+ |
private: |
typedef internal::InterfacePtrState<Interface> State; |
mutable State internal_state_; |