Title: [129314] trunk/Source/WTF
- Revision
- 129314
- Author
- [email protected]
- Date
- 2012-09-22 23:56:53 -0700 (Sat, 22 Sep 2012)
Log Message
Add explicit conversion operator to RetainPtr for easier use in C++11 environments
https://bugs.webkit.org/show_bug.cgi?id=97403
Reviewed by Dan Bernstein.
* wtf/Compiler.h:
Add support for COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS)
* wtf/RetainPtr.h:
(RetainPtr):
(WTF::RetainPtr::get):
(WTF::RetainPtr::operator PtrType):
Add the explicit conversion operator and group all the underlying
pointer accessors together.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (129313 => 129314)
--- trunk/Source/WTF/ChangeLog 2012-09-23 06:31:45 UTC (rev 129313)
+++ trunk/Source/WTF/ChangeLog 2012-09-23 06:56:53 UTC (rev 129314)
@@ -1,3 +1,20 @@
+2012-09-22 Sam Weinig <[email protected]>
+
+ Add explicit conversion operator to RetainPtr for easier use in C++11 environments
+ https://bugs.webkit.org/show_bug.cgi?id=97403
+
+ Reviewed by Dan Bernstein.
+
+ * wtf/Compiler.h:
+ Add support for COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS)
+
+ * wtf/RetainPtr.h:
+ (RetainPtr):
+ (WTF::RetainPtr::get):
+ (WTF::RetainPtr::operator PtrType):
+ Add the explicit conversion operator and group all the underlying
+ pointer accessors together.
+
2012-09-21 Simon Hausmann <[email protected]>
[Qt] Error out early if we don't have ICU available
Modified: trunk/Source/WTF/wtf/Compiler.h (129313 => 129314)
--- trunk/Source/WTF/wtf/Compiler.h 2012-09-23 06:31:45 UTC (rev 129313)
+++ trunk/Source/WTF/wtf/Compiler.h 2012-09-23 06:56:53 UTC (rev 129314)
@@ -57,10 +57,10 @@
#define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_extension(cxx_deleted_functions)
#define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr)
+#define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explicit_conversions)
#define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks)
#define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert)
#define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL __has_extension(cxx_override_control)
-
#define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial_destructor)
#endif
Modified: trunk/Source/WTF/wtf/RetainPtr.h (129313 => 129314)
--- trunk/Source/WTF/wtf/RetainPtr.h 2012-09-23 06:31:45 UTC (rev 129313)
+++ trunk/Source/WTF/wtf/RetainPtr.h 2012-09-23 06:56:53 UTC (rev 129314)
@@ -76,14 +76,16 @@
~RetainPtr() { if (PtrType ptr = m_ptr) CFRelease(ptr); }
template<typename U> RetainPtr(const RetainPtr<U>&);
-
- PtrType get() const { return m_ptr; }
void clear();
PtrType leakRef() WARN_UNUSED_RETURN;
+ PtrType get() const { return m_ptr; }
PtrType operator->() const { return m_ptr; }
-
+#if COMPILER_SUPPORTS(CXX_EXPLICIT_CONVERSIONS)
+ explicit operator PtrType() const { return m_ptr; }
+#endif
+
bool operator!() const { return !m_ptr; }
// This conversion operator allows implicit conversion to bool but not to other integer types.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes