OptionsSet initializer list constructor should be constexpr
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2018 15:35:29 +0000 (15:35 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2018 15:35:29 +0000 (15:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185298

Reviewed by Anders Carlsson.

* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231353 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/OptionSet.h

index 106a12a..d7509eb 100644 (file)
@@ -1,3 +1,13 @@
+2018-05-04  Antti Koivisto  <antti@apple.com>
+
+        OptionsSet initializer list constructor should be constexpr
+        https://bugs.webkit.org/show_bug.cgi?id=185298
+
+        Reviewed by Anders Carlsson.
+
+        * wtf/OptionSet.h:
+        (WTF::OptionSet::OptionSet):
+
 2018-05-03  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Use default std::optional if it is provided
index d063b5b..a1f1231 100644 (file)
@@ -78,16 +78,19 @@ public:
         : m_storage(static_cast<StorageType>(t))
     {
     }
+
+    constexpr OptionSet(std::initializer_list<T> initializerList)
+    {
+        for (auto& option : initializerList)
+            m_storage |= static_cast<StorageType>(option);
+    }
 #else
     OptionSet(T t)
         : m_storage(static_cast<StorageType>(t))
     {
         ASSERT_WITH_MESSAGE(hasOneBitSet(static_cast<StorageType>(t)), "Enumerator is not a positive power of two.");
     }
-#endif
 
-    // FIXME: Make this constexpr once we adopt C++14 as C++11 does not support for-loops
-    // in a constexpr function.
     OptionSet(std::initializer_list<T> initializerList)
     {
         for (auto& option : initializerList) {
@@ -95,6 +98,7 @@ public:
             m_storage |= static_cast<StorageType>(option);
         }
     }
+#endif
 
     constexpr StorageType toRaw() const { return m_storage; }