summaryrefslogtreecommitdiffstats
path: root/mfbt/Casting.h
diff options
context:
space:
mode:
authortrav90 <travawine@palemoon.org>2018-10-06 17:29:50 -0500
committertrav90 <travawine@palemoon.org>2018-10-06 17:29:50 -0500
commitc2fa384d666aea1b119736f33116ac09e870fda0 (patch)
tree643a1009d32e68df792526c79db4a4921a7b02ec /mfbt/Casting.h
parent323cb98de19b6f63b52d3fde5d7144712384c058 (diff)
downloadUXP-c2fa384d666aea1b119736f33116ac09e870fda0.tar
UXP-c2fa384d666aea1b119736f33116ac09e870fda0.tar.gz
UXP-c2fa384d666aea1b119736f33116ac09e870fda0.tar.lz
UXP-c2fa384d666aea1b119736f33116ac09e870fda0.tar.xz
UXP-c2fa384d666aea1b119736f33116ac09e870fda0.zip
Add mozilla::Span
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 */