Add missing subscript operator to `bsoncxx::vector::iterators` classes

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.3.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • C Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Observed the following compilation error when compiling against libc++ 22.1.0:

      ```
      error: type 'bsoncxx::v_noabi::vector::iterators::packed_bit_element<unsigned char *>' does not provide a subscript operator
      note: in instantiation of function template specialization 'std::sort<bsoncxx::v_noabi::vector::iterators::packed_bit_element<unsigned char *>>' [...]
      note: in instantiation of function template specialization '(anonymous namespace)::iterator_operations<bsoncxx::v_noabi::vector::iterators::packed_bit_element<unsigned char *>, bool>' [...]
      ```

      ```cpp
      auto vec = sbin.allocate(TestType{}, 8007u); // TestType = vector::formats::f_packed_bit
      iterator_operations(vec.begin(), vec.end(), std::ptrdiff_t(vec.size()), element_unit);
      // ...
      std::sort(begin, end); // error: [...]
      ```

      One or more improvements to the implementation of stdlib algorithms in LLVM 22.1.0 (see: [release notes](https://releases.llvm.org/22.1.0/projects/libcxx/docs/ReleaseNotes.html), [Compiler Explorer](https://compiler-explorer.com/z/8jMvPWqhE) appears to have exposed the absence of a subscript operator in the implementation of `bsoncxx::vector::iterators` despite its iterator category being [Cpp17RandomAccessIterator](https://timsong-cpp.github.io/cppwp/n3337/random.access.iterators).

            Assignee:
            Ezra Chung
            Reporter:
            Ezra Chung
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: