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

Add q20::exchange(), to have a replacement of qExchange() that is a) accessible to Qt itself and b) constexpr

XMLWordPrintable

    • 2
    • b5ed7fb20 (dev), cebb2dd06 (6.9), 7f3539202 (6.8)
    • Foundation Sprint 123

      We used to have qExchange(), but after it was extended twice (with constexpr (from C++20) and conditional noexcept (from C++23)), we didn't want to lock ourselves into this never-disappearing std wrapper, so we added QT_NO_QEXCHANGE and made all of Qt compile with that enabled.

      That leaves two holes, one much bigger than the other:

      • we have no constexpr exchange() anymore
      • we have no conditional noexcept exchange() anymore

      The latter doesn't matter much, as nothing in Qt queries the noexcept'ness of exchange() (it's easily expressed by std type traits), but the former prevents us from writing idiomatic code (like in QScopedValueRollback, where we need to emulate exchange() using two move()s instead.

      There are other potential users (basically, any non-trivial Literal Type move-constructible type), so we should really add q20::exchange(). q23::exchange() doesn't appear needed, at this point in time.

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

            mmutz Marc Mutz
            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:
              Resolved:

                There are no open Gerrit changes