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

QLatin1StringView documentation assumes knowledge of string literals namespace

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.9
    • Documentation
    • framework-content 10

    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

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

        Activity

          People

            docteam Qt Documentation Team
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes