Skip to content

Commit

Permalink
Add missing #include <algorithm> for std::min/std::max uses, and #inc…
Browse files Browse the repository at this point in the history
…lude <limits> for std::numeric_limits<> (#7624)
  • Loading branch information
rouault committed Nov 8, 2022
1 parent 214cc94 commit a22434e
Show file tree
Hide file tree
Showing 19 changed files with 32 additions and 5 deletions.
4 changes: 3 additions & 1 deletion include/flatbuffers/buffer.h
Expand Up @@ -17,6 +17,8 @@
#ifndef FLATBUFFERS_BUFFER_H_
#define FLATBUFFERS_BUFFER_H_

#include <algorithm>

#include "flatbuffers/base.h"

namespace flatbuffers {
Expand Down Expand Up @@ -149,4 +151,4 @@ template<typename T> const T *GetSizePrefixedRoot(const void *buf) {

} // namespace flatbuffers

#endif // FLATBUFFERS_BUFFER_H_
#endif // FLATBUFFERS_BUFFER_H_
1 change: 1 addition & 0 deletions include/flatbuffers/flatbuffer_builder.h
Expand Up @@ -17,6 +17,7 @@
#ifndef FLATBUFFERS_FLATBUFFER_BUILDER_H_
#define FLATBUFFERS_FLATBUFFER_BUILDER_H_

#include <algorithm>
#include <functional>
#include <initializer_list>

Expand Down
2 changes: 2 additions & 0 deletions include/flatbuffers/flatbuffers.h
Expand Up @@ -17,6 +17,8 @@
#ifndef FLATBUFFERS_H_
#define FLATBUFFERS_H_

#include <algorithm>

// TODO: These includes are for mitigating the pains of users editing their
// source because they relied on flatbuffers.h to include everything for them.
#include "flatbuffers/array.h"
Expand Down
1 change: 1 addition & 0 deletions include/flatbuffers/flexbuffers.h
Expand Up @@ -17,6 +17,7 @@
#ifndef FLATBUFFERS_FLEXBUFFERS_H_
#define FLATBUFFERS_FLEXBUFFERS_H_

#include <algorithm>
#include <map>
// Used to select STL variant.
#include "flatbuffers/base.h"
Expand Down
1 change: 1 addition & 0 deletions include/flatbuffers/idl.h
Expand Up @@ -17,6 +17,7 @@
#ifndef FLATBUFFERS_IDL_H_
#define FLATBUFFERS_IDL_H_

#include <algorithm>
#include <functional>
#include <map>
#include <memory>
Expand Down
1 change: 1 addition & 0 deletions include/flatbuffers/util.h
Expand Up @@ -31,6 +31,7 @@
# include <stdio.h>
#endif // FLATBUFFERS_PREFER_PRINTF

#include <limits>
#include <string>

namespace flatbuffers {
Expand Down
2 changes: 2 additions & 0 deletions include/flatbuffers/vector_downward.h
Expand Up @@ -17,6 +17,8 @@
#ifndef FLATBUFFERS_VECTOR_DOWNWARD_H_
#define FLATBUFFERS_VECTOR_DOWNWARD_H_

#include <algorithm>

#include "flatbuffers/base.h"
#include "flatbuffers/default_allocator.h"
#include "flatbuffers/detached_buffer.h"
Expand Down
1 change: 1 addition & 0 deletions src/annotated_binary_text_gen.cpp
@@ -1,5 +1,6 @@
#include "annotated_binary_text_gen.h"

#include <algorithm>
#include <sstream>
#include <string>

Expand Down
3 changes: 2 additions & 1 deletion src/binary_annotator.cpp
@@ -1,5 +1,6 @@
#include "binary_annotator.h"

#include <algorithm>
#include <limits>
#include <string>
#include <vector>
Expand Down Expand Up @@ -1416,4 +1417,4 @@ bool BinaryAnnotator::ContainsSection(const uint64_t offset) {
it->second.regions.back().length;
}

} // namespace flatbuffers
} // namespace flatbuffers
2 changes: 2 additions & 0 deletions src/flatc.cpp
Expand Up @@ -16,6 +16,8 @@

#include "flatbuffers/flatc.h"

#include <algorithm>
#include <limits>
#include <list>
#include <sstream>

Expand Down
1 change: 1 addition & 0 deletions src/idl_gen_cpp.cpp
Expand Up @@ -16,6 +16,7 @@

// independent from idl_parser, since this code is not needed for most clients

#include <limits>
#include <string>
#include <unordered_set>

Expand Down
1 change: 1 addition & 0 deletions src/idl_gen_go.cpp
Expand Up @@ -16,6 +16,7 @@

// independent from idl_parser, since this code is not needed for most clients

#include <algorithm>
#include <sstream>
#include <string>

Expand Down
2 changes: 2 additions & 0 deletions src/idl_gen_json_schema.cpp
Expand Up @@ -14,7 +14,9 @@
* limitations under the License.
*/

#include <algorithm>
#include <iostream>
#include <limits>

#include "flatbuffers/code_generators.h"
#include "flatbuffers/idl.h"
Expand Down
2 changes: 2 additions & 0 deletions src/idl_gen_text.cpp
Expand Up @@ -16,6 +16,8 @@

// independent from idl_parser, since this code is not needed for most clients

#include <algorithm>

#include "flatbuffers/flatbuffers.h"
#include "flatbuffers/flexbuffers.h"
#include "flatbuffers/idl.h"
Expand Down
4 changes: 3 additions & 1 deletion tests/flexbuffers_test.cpp
@@ -1,3 +1,5 @@
#include <limits>

#include "flexbuffers_test.h"

#include "flatbuffers/flexbuffers.h"
Expand Down Expand Up @@ -289,4 +291,4 @@ void ParseFlexbuffersFromJsonWithNullTest() {
}

} // namespace tests
} // namespace flatbuffers
} // namespace flatbuffers
4 changes: 3 additions & 1 deletion tests/fuzz_test.cpp
@@ -1,3 +1,5 @@
#include <algorithm>

#include "fuzz_test.h"

#include "flatbuffers/flatbuffers.h"
Expand Down Expand Up @@ -302,4 +304,4 @@ void FuzzTest2() {
}

} // namespace tests
} // namespace flatbuffers
} // namespace flatbuffers
3 changes: 2 additions & 1 deletion tests/monster_test.cpp
@@ -1,5 +1,6 @@
#include "monster_test.h"

#include <limits>
#include <vector>

#include "flatbuffers/flatbuffer_builder.h"
Expand Down Expand Up @@ -852,4 +853,4 @@ void UnPackTo(const uint8_t *flatbuf) {
}

} // namespace tests
} // namespace flatbuffers
} // namespace flatbuffers
1 change: 1 addition & 0 deletions tests/parser_test.cpp
@@ -1,6 +1,7 @@
#include "parser_test.h"

#include <cmath>
#include <limits>
#include <string>

#include "flatbuffers/idl.h"
Expand Down
1 change: 1 addition & 0 deletions tests/test.cpp
Expand Up @@ -16,6 +16,7 @@
#include <stdint.h>

#include <cmath>
#include <limits>
#include <memory>
#include <string>

Expand Down

0 comments on commit a22434e

Please sign in to comment.