diff options
-rw-r--r-- | include/flatbuffers/idl.h | 9 | ||||
-rw-r--r-- | src/idl_gen_go.cpp | 8 |
2 files changed, 16 insertions, 1 deletions
diff --git a/include/flatbuffers/idl.h b/include/flatbuffers/idl.h index 359cc680..729917a8 100644 --- a/include/flatbuffers/idl.h +++ b/include/flatbuffers/idl.h @@ -231,6 +231,15 @@ struct Namespace { size_t from_table; // Part of the namespace corresponds to a message/table. }; +inline bool operator<(const Namespace &a, const Namespace &b) { + size_t min_size = std::min(a.components.size(), b.components.size()); + for (size_t i = 0; i < min_size; ++i) { + if (a.components[i] != b.components[i]) + return a.components[i] < b.components[i]; + } + return a.components.size() < b.components.size(); +} + // Base class for all definition types (fields, structs_, enums_). struct Definition { Definition() diff --git a/src/idl_gen_go.cpp b/src/idl_gen_go.cpp index f6119cb3..8efbdc8d 100644 --- a/src/idl_gen_go.cpp +++ b/src/idl_gen_go.cpp @@ -113,7 +113,13 @@ class GoGenerator : public BaseGenerator { private: Namespace go_namespace_; Namespace *cur_name_space_; - std::set<const Namespace*> tracked_imported_namespaces_; + + struct NamespacePtrLess { + bool operator()(const Namespace *a, const Namespace *b) const { + return *a < *b; + } + }; + std::set<const Namespace *, NamespacePtrLess> tracked_imported_namespaces_; // Most field accessors need to retrieve and test the field offset first, // this is the prefix code for that. |