Bug 1600906 - Made FlippedOnce member functions constexpr. r=dom-workers-and-storage-reviewers,ytausky
authorSimon Giesecke <sgiesecke@mozilla.com>
Fri, 13 Dec 2019 10:54:48 +0000
changeset 506863 7a3e7318e28eb03c7fd18bba490cd94a1ae826f9
parent 506862 0989faf6b5f197db133e1726fc5f746cb98fc683
child 506864 26d96c797b0f185cd20aa4d70a5ca1abf637f93f
push id36913
push useropoprus@mozilla.com
push dateFri, 13 Dec 2019 16:53:24 +0000
treeherdermozilla-central@1ed684598bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdom-workers-and-storage-reviewers, ytausky
bugs1600906
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1600906 - Made FlippedOnce member functions constexpr. r=dom-workers-and-storage-reviewers,ytausky Differential Revision: https://phabricator.services.mozilla.com/D56007
dom/indexedDB/FlippedOnce.h
--- a/dom/indexedDB/FlippedOnce.h
+++ b/dom/indexedDB/FlippedOnce.h
@@ -14,26 +14,28 @@ namespace mozilla {
 
 // A state-restricted bool, which can only be flipped once. It isn't required to
 // be flipped during its lifetime.
 template <bool Initial>
 class FlippedOnce {
  public:
   FlippedOnce(const FlippedOnce&) = delete;
   FlippedOnce& operator=(const FlippedOnce&) = delete;
-
-  FlippedOnce() = default;
+  FlippedOnce(FlippedOnce&&) = default;
+  FlippedOnce& operator=(FlippedOnce&&) = default;
 
-  MOZ_IMPLICIT operator bool() const { return mValue; };
+  constexpr FlippedOnce() = default;
 
-  void Flip() {
+  MOZ_IMPLICIT constexpr operator bool() const { return mValue; };
+
+  constexpr void Flip() {
     MOZ_ASSERT(mValue == Initial);
     EnsureFlipped();
   }
 
-  void EnsureFlipped() { mValue = !Initial; }
+  constexpr void EnsureFlipped() { mValue = !Initial; }
 
  private:
   bool mValue = Initial;
 };
 }  // namespace mozilla
 
 #endif