mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-05-16 20:31:20 +00:00
ParamGenerator: Return the end iterator if any param is empty
Not doing so produces an infinite loop when iterating from begin to end. Bug: none Change-Id: I323587a19ba1618d7e9a326de2ee398ae5e0bb7b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/51762 Auto-Submit: Austin Eng <enga@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
parent
aa11652207
commit
8bc3e68bd1
@ -46,7 +46,10 @@ class ParamGenerator {
|
|||||||
public:
|
public:
|
||||||
using value_type = ParamStruct;
|
using value_type = ParamStruct;
|
||||||
|
|
||||||
ParamGenerator(std::vector<Params>... params) : mParams(params...) {
|
ParamGenerator(std::vector<Params>... params) : mParams(params...), mIsEmpty(false) {
|
||||||
|
for (bool isEmpty : {params.empty()...}) {
|
||||||
|
mIsEmpty |= isEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Iterator : public std::iterator<std::forward_iterator_tag, ParamStruct, size_t> {
|
class Iterator : public std::iterator<std::forward_iterator_tag, ParamStruct, size_t> {
|
||||||
@ -94,6 +97,9 @@ class ParamGenerator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Iterator begin() const {
|
Iterator begin() const {
|
||||||
|
if (mIsEmpty) {
|
||||||
|
return end();
|
||||||
|
}
|
||||||
return Iterator(mParams, {});
|
return Iterator(mParams, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,6 +111,7 @@ class ParamGenerator {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ParamTuple mParams;
|
ParamTuple mParams;
|
||||||
|
bool mIsEmpty;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BackendTestConfig;
|
struct BackendTestConfig;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user