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

Ambigious overload of operator<<(QDBusArgument &arg, const Container<Key, T> &map) for QMap with nested pairs

    XMLWordPrintable

Details

    • Linux/X11
    • 5401a9a6c (dev), 9ffed81b1 (6.7), 1e11f8fa8 (6.6), bb3d6f96a (tqtc/lts-6.5)

    Description

      The following code fails to compile:

      QMap<QString, std::pair<int, int>> map {};
      QDBusArgument arg;
      arg << map;

      because the call to to operator<< is ambiguous (two possible calls in qdbusargument.h):
       
       

      template <template <typename, typename> class Container, typename Key, typename T,
               QtPrivate::IfAssociativeIteratorHasKeyAndValue<typename Container<Key, T>::iterator> = true>
      inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &map); 

      and
       

      template <template <typename, typename> class Container, typename Key, typename T,
               QtPrivate::IfAssociativeIteratorHasFirstAndSecond<typename Container<Key, T>::iterator> = true>
      inline QDBusArgument &operator<<(QDBusArgument &arg, const Container<Key, T> &map); 

      The iterator type of the map has both, key()/value() methods from the map itself and first/second access through operator-> of the map.Hence, both functions match. Obviously, the first one should be the correct one to call in this case.
       
      Is this the expected behavior?

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            ltoenning Lars Toenning
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews