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

QUrlQuery: missing move constructor

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.0, 6.6.0
    • 5.15, 6.2, 6.4
    • Core: I/O
    • None
    • fc8dad2f1 (dev), 03635c267 (6.5), 577276d12 (dev), 666944615 (6.5)

    Description

      QUrlQuery has no move constructor despite having swap and move assignment. Because QUrlQuery fails to implement rule-of-5 this breaks types that have QUrlQuery members from being able to rely on rule-of-0.

       

          static_assert(std::is_nothrow_move_assignable_v<QUrlQuery>); // ok
          static_assert(std::is_nothrow_move_constructible_v<QUrlQuery>); // fails

      Workaround for types that want to rely on rule-of-0: default 4 special member functions and implement move constructor by swapping QUrlQuery objects.

      class X
      {
      public:
          X() = default;
          ~X() = default;
          X(const X& other) = default;
          X& operator=(const X& other) = default;
          X(X&& other) noexcept
              // (std::move all members here except QUrlQuery)
              // (QUrlQuery will be default-constructed)
          {
              query.swap(other.query);
          }
          X& operator=(X&& other) noexcept = default;
          
      private:
          // other members...
          QUrlQuery query;
      }; 

      Attachments

        For Gerrit Dashboard: QTBUG-109842
        # Subject Branch Project Status CR V

        Activity

          People

            thiago Thiago Macieira
            michal_urbanski Michał Urbański
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes