ityp_array: Allow using a T whose underlying type is signed.
When trying to use ityp_array with an enum class whose underlying type is int, warnings were fired because of a comparison between signed and unsigned integers. Fix this by explicitly casting Size to `I` using a constructor cast. Bug: dawn:635 Change-Id: I5ee0101684e5847ec5ec6f71a9657fcce839a2a5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/38106 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
774f601db4
commit
762814bd92
|
@ -44,25 +44,25 @@ namespace ityp {
|
|||
|
||||
Value& operator[](Index i) {
|
||||
I index = static_cast<I>(i);
|
||||
ASSERT(index >= 0 && index < Size);
|
||||
ASSERT(index >= 0 && index < I(Size));
|
||||
return Base::operator[](index);
|
||||
}
|
||||
|
||||
constexpr const Value& operator[](Index i) const {
|
||||
I index = static_cast<I>(i);
|
||||
ASSERT(index >= 0 && index < Size);
|
||||
ASSERT(index >= 0 && index < I(Size));
|
||||
return Base::operator[](index);
|
||||
}
|
||||
|
||||
Value& at(Index i) {
|
||||
I index = static_cast<I>(i);
|
||||
ASSERT(index >= 0 && index < Size);
|
||||
ASSERT(index >= 0 && index < I(Size));
|
||||
return Base::at(index);
|
||||
}
|
||||
|
||||
constexpr const Value& at(Index i) const {
|
||||
I index = static_cast<I>(i);
|
||||
ASSERT(index >= 0 && index < Size);
|
||||
ASSERT(index >= 0 && index < I(Size));
|
||||
return Base::at(index);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace ityp {
|
|||
}
|
||||
|
||||
constexpr Index size() const {
|
||||
return Index(static_cast<I>(Size));
|
||||
return Index(I(Size));
|
||||
}
|
||||
|
||||
using Base::back;
|
||||
|
|
Loading…
Reference in New Issue