Skip to content

Commit

Permalink
use auto instead of size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
Wen Sun committed Dec 5, 2022
1 parent 730c1fc commit 6d3431e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/idl_gen_cpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2312,7 +2312,7 @@ class CppGenerator : public BaseGenerator {
code_ +=
" const {{INPUT_TYPE}} *curr_{{FIELD_NAME}} = {{FIELD_NAME}}();";
code_ +=
" for (size_t i = 0; i < curr_{{FIELD_NAME}}->size(); i++) {";
" for (auto i = 0; i < curr_{{FIELD_NAME}}->size(); i++) {";
code_ += " const auto lhs = curr_{{FIELD_NAME}}->Get(i);";
code_ += " const auto rhs = _{{FIELD_NAME}}->Get(i);";
code_ += " if(lhs != rhs) ";
Expand Down
12 changes: 6 additions & 6 deletions tests/key_field/key_field_sample_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(1) Baz FLATBUFFERS_FINAL_CLASS {
bool KeyCompareLessThan(const Baz * const o) const {
return KeyCompareWithValue(o->a()) < 0;
}
int KeyCompareWithValue(const flatbuffers::Array<uint8_t, 4> *_a) const {
int KeyCompareWithValue(const flatbuffers::Array<uint8_t, 4> *_a) const {
const flatbuffers::Array<uint8_t, 4> *curr_a = a();
for (size_t i = 0; i < curr_a->size(); i++) {
for (auto i = 0; i < curr_a->size(); i++) {
const auto lhs = curr_a->Get(i);
const auto rhs = _a->Get(i);
if(lhs != rhs)
if(lhs != rhs)
return static_cast<int>(lhs > rhs) - static_cast<int>(lhs < rhs);
}
return 0;
Expand Down Expand Up @@ -140,12 +140,12 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Bar FLATBUFFERS_FINAL_CLASS {
bool KeyCompareLessThan(const Bar * const o) const {
return KeyCompareWithValue(o->a()) < 0;
}
int KeyCompareWithValue(const flatbuffers::Array<float, 3> *_a) const {
int KeyCompareWithValue(const flatbuffers::Array<float, 3> *_a) const {
const flatbuffers::Array<float, 3> *curr_a = a();
for (size_t i = 0; i < curr_a->size(); i++) {
for (auto i = 0; i < curr_a->size(); i++) {
const auto lhs = curr_a->Get(i);
const auto rhs = _a->Get(i);
if(lhs != rhs)
if(lhs != rhs)
return static_cast<int>(lhs > rhs) - static_cast<int>(lhs < rhs);
}
return 0;
Expand Down

0 comments on commit 6d3431e

Please sign in to comment.