mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-06 13:15:59 +00:00
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) {
|
Value& operator[](Index i) {
|
||||||
I index = static_cast<I>(i);
|
I index = static_cast<I>(i);
|
||||||
ASSERT(index >= 0 && index < Size);
|
ASSERT(index >= 0 && index < I(Size));
|
||||||
return Base::operator[](index);
|
return Base::operator[](index);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const Value& operator[](Index i) const {
|
constexpr const Value& operator[](Index i) const {
|
||||||
I index = static_cast<I>(i);
|
I index = static_cast<I>(i);
|
||||||
ASSERT(index >= 0 && index < Size);
|
ASSERT(index >= 0 && index < I(Size));
|
||||||
return Base::operator[](index);
|
return Base::operator[](index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value& at(Index i) {
|
Value& at(Index i) {
|
||||||
I index = static_cast<I>(i);
|
I index = static_cast<I>(i);
|
||||||
ASSERT(index >= 0 && index < Size);
|
ASSERT(index >= 0 && index < I(Size));
|
||||||
return Base::at(index);
|
return Base::at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr const Value& at(Index i) const {
|
constexpr const Value& at(Index i) const {
|
||||||
I index = static_cast<I>(i);
|
I index = static_cast<I>(i);
|
||||||
ASSERT(index >= 0 && index < Size);
|
ASSERT(index >= 0 && index < I(Size));
|
||||||
return Base::at(index);
|
return Base::at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ namespace ityp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr Index size() const {
|
constexpr Index size() const {
|
||||||
return Index(static_cast<I>(Size));
|
return Index(I(Size));
|
||||||
}
|
}
|
||||||
|
|
||||||
using Base::back;
|
using Base::back;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user