Bug 869194 - CheckedInt should consistently reject unsupported types - r=Waldo

This commit is contained in:
Benoit Jacob 2013-05-08 17:25:15 -04:00
parent b6ecd61d8f
commit 3701ad32bf

View File

@ -561,7 +561,8 @@ class CheckedInt
template<typename U>
CheckedInt(U value, bool isValid) : mValue(value), mIsValid(isValid)
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value,
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
}
@ -584,7 +585,8 @@ class CheckedInt
: mValue(T(value)),
mIsValid(detail::IsInRange<T>(value))
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value,
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
}
@ -755,6 +757,9 @@ template<typename T, typename U>
inline typename detail::CastToCheckedIntImpl<T, U>::ReturnType
castToCheckedInt(U u)
{
MOZ_STATIC_ASSERT(detail::IsSupported<T>::value &&
detail::IsSupported<U>::value,
"This type is not supported by CheckedInt");
return detail::CastToCheckedIntImpl<T, U>::run(u);
}