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

Add STL-style assign() overload sets to Qt containers.

XMLWordPrintable

    • container-assign

      Qt container are lacking the assign() overloads of STL containers:

      These functions are a convenient way to assign new data while reusing the allocated memory:

      std::string s;
      s.assign(p1, n1); // probably allocates
      s.assign(p2, n2); // may not allocate, if n1 >= n2
      
      QByteArray s;
      s = QByteArray(p1, n1); // allocates
      s = QByteArray(p2, n2); // allocates, too, even if n2 <= n1
      

      The STL views (string_view) don't have the assign() function, so it's basically the owning Qt containers:

      • QByteArray
      • QString
      • QList
      • QVLA

      We should also look around the Qt code to find potential users of the new functions.

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

            cnn Qt Core & Network
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes