Title: [233836] trunk/Source/WTF
Revision
233836
Author
[email protected]
Date
2018-07-14 09:59:54 -0700 (Sat, 14 Jul 2018)

Log Message

Replace TR2_OPTIONAL_ASSERTED_EXPRESSION macro in <wtf/Optional.h>
<https://webkit.org/b/187672>

Reviewed by Frédéric Wang.

* wtf/Optional.h:
(std::optional::operator -> const):
(std::optional::operator * const):
(std::optional<T::operator-> const):
(std::optional<T::operator* const):
- Replace TR2_OPTIONAL_ASSERTED_EXPRESSION macro with
  ASSERT_UNDER_CONSTEXPR_CONTEXT macro and return statement.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (233835 => 233836)


--- trunk/Source/WTF/ChangeLog	2018-07-14 09:19:46 UTC (rev 233835)
+++ trunk/Source/WTF/ChangeLog	2018-07-14 16:59:54 UTC (rev 233836)
@@ -1,3 +1,18 @@
+2018-07-14  David Kilzer  <[email protected]>
+
+        Replace TR2_OPTIONAL_ASSERTED_EXPRESSION macro in <wtf/Optional.h>
+        <https://webkit.org/b/187672>
+
+        Reviewed by Frédéric Wang.
+
+        * wtf/Optional.h:
+        (std::optional::operator -> const):
+        (std::optional::operator * const):
+        (std::optional<T::operator-> const):
+        (std::optional<T::operator* const):
+        - Replace TR2_OPTIONAL_ASSERTED_EXPRESSION macro with
+          ASSERT_UNDER_CONSTEXPR_CONTEXT macro and return statement.
+
 2018-07-13  Mark Lam  <[email protected]>
 
         Signal.cpp's activeThreads() should only create its ThreadGroup once.

Modified: trunk/Source/WTF/wtf/Optional.h (233835 => 233836)


--- trunk/Source/WTF/wtf/Optional.h	2018-07-14 09:19:46 UTC (rev 233835)
+++ trunk/Source/WTF/wtf/Optional.h	2018-07-14 16:59:54 UTC (rev 233836)
@@ -235,13 +235,7 @@
     return static_cast<typename std::remove_reference<T>::type&&>(t);
 }
 
-#if defined NDEBUG
-# define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR)
-#else
-# define TR2_OPTIONAL_ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : ([]{assert(!#CHECK);}(), (EXPR)))
-#endif
 
-
 // static_addressof: a constexpr version of addressof
 template <typename T>
 struct has_overloaded_addressof
@@ -526,7 +520,8 @@
   constexpr bool has_value() const __NOEXCEPT { return initialized(); }
 
   constexpr T const* operator ->() const {
-    return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), dataptr());
+    ASSERT_UNDER_CONSTEXPR_CONTEXT(initialized());
+    return dataptr();
   }
 
   OPTIONAL_MUTABLE_CONSTEXPR T* operator ->() {
@@ -535,7 +530,8 @@
   }
 
   constexpr T const& operator *() const& {
-    return TR2_OPTIONAL_ASSERTED_EXPRESSION(initialized(), contained_val());
+    ASSERT_UNDER_CONSTEXPR_CONTEXT(initialized());
+    return contained_val();
   }
 
   OPTIONAL_MUTABLE_CONSTEXPR T& operator *() & {
@@ -669,11 +665,13 @@
 
   // 20.5.5.3, observers
   constexpr T* operator->() const {
-    return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, ref);
+    ASSERT_UNDER_CONSTEXPR_CONTEXT(ref);
+    return ref;
   }
 
   constexpr T& operator*() const {
-    return TR2_OPTIONAL_ASSERTED_EXPRESSION(ref, *ref);
+    ASSERT_UNDER_CONSTEXPR_CONTEXT(ref);
+    return *ref;
   }
 
   constexpr T& value() const {
@@ -1035,7 +1033,6 @@
 }
 
 # undef TR2_OPTIONAL_REQUIRES
-# undef TR2_OPTIONAL_ASSERTED_EXPRESSION
 
 #endif // defined(__cpp_lib_optional)
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to