From c2fa384d666aea1b119736f33116ac09e870fda0 Mon Sep 17 00:00:00 2001 From: trav90 Date: Sat, 6 Oct 2018 17:29:50 -0500 Subject: Add mozilla::Span --- mfbt/Casting.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mfbt/Casting.h') 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(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 +inline To +ReleaseAssertedCast(const From aFrom) +{ + MOZ_RELEASE_ASSERT((detail::IsInBounds(aFrom))); + return static_cast(aFrom); +} + } // namespace mozilla #endif /* mozilla_Casting_h */ -- cgit v1.2.3