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

QLatin1StringView documentation assumes knowledge of string literals namespace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.9
    • Documentation
    • None
    • 72becc7c1 (dev), 78f9131ef (6.9)
    • framework-content 10, framework-content 11

      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;
      

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

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

              Created:
              Updated:

                There are no open Gerrit changes