diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-10-08 08:15:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 08:15:08 +0200 |
commit | 7e96154b878e6e08ccc1220ad252aeac312d4753 (patch) | |
tree | 7a1f7869bdbe1c66652d1af8a21d2182ee4db1f1 /mfbt/Casting.h | |
parent | 0357bf9fb69f745274b36c4e3649fe5ba6edbad9 (diff) | |
parent | a08ef72265f270f7b0925a0ee9f5c6cee4187c6d (diff) | |
download | UXP-7e96154b878e6e08ccc1220ad252aeac312d4753.tar UXP-7e96154b878e6e08ccc1220ad252aeac312d4753.tar.gz UXP-7e96154b878e6e08ccc1220ad252aeac312d4753.tar.lz UXP-7e96154b878e6e08ccc1220ad252aeac312d4753.tar.xz UXP-7e96154b878e6e08ccc1220ad252aeac312d4753.zip |
Merge pull request #818 from trav90/mfbt-work
Add mozilla::Span
Diffstat (limited to 'mfbt/Casting.h')
-rw-r--r-- | mfbt/Casting.h | 13 |
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 */ |