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

QLatin1StringView documentation assumes knowledge of string literals namespace

    XMLWordPrintable

Details

    • 72becc7c1 (dev), 78f9131ef (6.9)
    • framework-content 10, framework-content 11

    Description

      https://doc.qt.io/qt-6/qlatin1stringview.html#details has a snippet that uses _L1:

      if (str == "auto"_L1
              || str == "extern"_L1
              || str == "static"_L1
              || str == "register"_L1 {
          ...
      }
      

      This code won't compile unless the user has made those literals available:

          /home/mitch/dev/temp/quick2/main.cpp:29:20: error: unable to find string literal operator ‘operator""_L1’ with ‘const char [5]’, ‘long unsigned int’ arguments
             29 |     const auto t = "test"_L1;
                |                    ^~~~~~~~~    
      

      The error gives the user no help, so the only solution is to document the namespace whenever these literals are used:

      using namespace Qt::Literals::StringLiterals;
      

      Attachments

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

        Activity

          People

            lexcaz Alexei Cazacov
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes