summaryrefslogtreecommitdiffstats
path: root/mfbt/Casting.h
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-10-24 11:13:33 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-10-24 11:13:33 +0200
commit579881ffb4aa0b145c793825cd1b0628e7cd6cdc (patch)
tree65d59fc6b73f120ac1bc2214d4a8442421076b04 /mfbt/Casting.h
parenta02c44648a3f7d6f3904eebba026ce5e6f781bef (diff)
parentf71c04d814416ebf52dd54109f2d04f1cbd397c0 (diff)
downloadUXP-579881ffb4aa0b145c793825cd1b0628e7cd6cdc.tar
UXP-579881ffb4aa0b145c793825cd1b0628e7cd6cdc.tar.gz
UXP-579881ffb4aa0b145c793825cd1b0628e7cd6cdc.tar.lz
UXP-579881ffb4aa0b145c793825cd1b0628e7cd6cdc.tar.xz
UXP-579881ffb4aa0b145c793825cd1b0628e7cd6cdc.zip
Merge branch 'master' into Sync-weave
Diffstat (limited to 'mfbt/Casting.h')
-rw-r--r--mfbt/Casting.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/mfbt/Casting.h b/mfbt/Casting.h
index a7d0fb50d..adf2c9045 100644
--- a/mfbt/Casting.h
+++ b/mfbt/Casting.h
@@ -238,6 +238,19 @@ AssertedCast(const From aFrom)
return static_cast<To>(aFrom);
}
+/**
+ * Cast a value of integral type |From| to a value of integral type |To|,
+ * release asserting that the cast will be a safe cast per C++ (that is, that
+ * |to| is in the range of values permitted for the type |From|).
+ */
+template<typename To, typename From>
+inline To
+ReleaseAssertedCast(const From aFrom)
+{
+ MOZ_RELEASE_ASSERT((detail::IsInBounds<From, To>(aFrom)));
+ return static_cast<To>(aFrom);
+}
+
} // namespace mozilla
#endif /* mozilla_Casting_h */