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

Should we provide helper macros for std::format support?

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • Core: Other
    • None

    Description

      If we decide to provide std::format support for Qt classes, we might want to think of a way to simplify this work to Qt module maintainters.

      Similarly to C++20 comparison, we might want to provide helper macros. These macros might provide the necessary std::formatter<T, CharT> specializations, and just require the user to provide some helper function that will be used by std::formatter::format().

      In the most trivial case, if we support only the default formatting string "{}", the function can be as simple as:

      friend std::string toString(const MyType &t);
      

      Technically, we could even use the qDebug() streaming operators, because after https://codereview.qt-project.org/c/qt/qtbase/+/577581 gets merged, we would avoid an unnecessary UTF-16 string.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            ivan.solovev Ivan Solovev
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes