Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-57353

QJsonObject::iterator cannot be subtracted, as required for random-access iterators

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 5.6.0, 5.7.0
    • None
    • d0b83adfe7b1d31db2e3febdd2638da0b1a13a0c (qt/qtbase/5.15)

    Description

      QJsonObject::iterator has iterator_category defined as std::random_access_iterator_tag, but does not implement the requirements for random-access iterators defined by the C++ standard. This causes many standard library algorithms to fail.

      Specifically, given iterators a and b, the expression `a - b` must be valid, and return the distance between the two iterators. (see http://en.cppreference.com/w/cpp/concept/RandomAccessIterator)

      Because the iterators promise to conform to the random access iterator concept, but don't actually implement the required interface, any code using standard library algorithms such as std::all_of fails to compile.

      According to the class' documentation, the class was (correctly) tagged as a bidirectional iterator prior to 5.6. Perhaps that change should simply be reverted.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            jalf jalf
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes