BSONObjStlIterator uses C++20 range style range

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      • end() is allowed to return a different type (a sentinel), so operator== knows when it is doing an end check, and can do >= like BSONObj, rather than ==. This ensures that if we somehow end up past the end we exit the loop rather than continuing forever. Alternatively, we could throw in the > case, since something is very wrong if we get there.
      • operator* doesn't need to return a `T&`, so we can return a BSONElement by value rather than storing one as a member. This gives us more flexibility in how we represent the data in the iterator.
      • Consider implementing a BSONObj std::ranges::view_interface

            Assignee:
            Alex Li
            Reporter:
            Alex Li
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: