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

QMap: making it more STL compatible

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.1.0 RC1
    • None
    • all environment

      The story:

      On a French forum, someone asked how to implement the <operator for QPoint.

      My response was to prefer a functor, because there are (at least) two ways to compare the point by the the X-axis value and then the Y-axis value and the Y-axis value and then X-axis value

      The idea of ​​the PO (good or bad?) was to use the QPoint like a key in a QMap.

      But if it is possible to use a user defined comparison with std :: map, QMap does not provide such a possibility.

      Memory: the full definition of std :: map is
      template <typename Key, value, typename = typename Comp std::less>
      class map

      {/ * ... * /}

      ;}

      Since QMap provides a constructor QMap (std :: map <Key, Value> const &), would not it be nice to add a third template parameter for comparison to STL QMap more consistent and increase its capacity?

      I have not checked the implementation of QMap, but I think most of the changes are expected to occur in the comparison function (which would then use the comparator and not the "<" operator?).

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

            laknoll Lars Knoll
            koala01 philippe dunski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes