Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator cannot parse lambda with parameter involved with decltype
QtWS25 Last Chance

Qt Creator cannot parse lambda with parameter involved with decltype

Scheduled Pinned Locked Moved Qt Creator and other tools
qt creatorc++11
7 Posts 2 Posters 3.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    blazar
    wrote on 22 Jun 2015, 07:13 last edited by
    #1

    I'm using Qt 5.4.2 and Qt Creator 3.4.1.
    I'm found that Qt Creator parse lambda parameter with decltype incorrectly.
    for example
    this works fine if parameter type without decltype

    std::map<std::string, std::string> someMap;
    std::vector<std::string> targetVector;
    std::transform(someMap.begin(), someMap.end(),
                   std::back_inserter(targetVector),
                   [](const std::map<std::string, std::string>::value_type &pair) -> const std::string { return pair.first; });
    

    however if I'm using decltype in parameter type

    std::map<std::string, std::string> someMap;
    std::vector<std::string> targetVector;
    std::transform(someMap.begin(), someMap.end(),
                   std::back_inserter(targetVector),
                   [](const decltype(someMap)::value_type &pair) -> const std::string { return pair.first; });
    

    Qt Creator shows

    expected token `;` got `const`
    

    Is this bug or shouldn't I declare parameter in this way?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 22 Jun 2015, 09:51 last edited by
      #2

      If I understand you correctly, you are getting a compiler error, right? In that case, this has nothing to do with Qt Creator.

      Or are you talking about an error in Qt Creator's C++ code model?

      (Z(:^

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blazar
        wrote on 22 Jun 2015, 13:54 last edited by
        #3

        It's an error in Qt Creator code model, which highlight the code as syntax error, which I don't think so.
        And it compiles without any error and warning under gcc 4.8.2 and -std=c++11.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 22 Jun 2015, 16:08 last edited by
          #4

          OK thanks, now the issue is clear. Please see if it is not known already and if not report it: here are the instructions on how to do it.

          (Z(:^

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sierdzio
            Moderators
            wrote on 22 Jun 2015, 16:08 last edited by
            #5

            Also, as a temporary workaround, you can try turning on the Clang code model plugin - maybe it will help you.

            (Z(:^

            1 Reply Last reply
            0
            • B Offline
              B Offline
              blazar
              wrote on 23 Jun 2015, 02:47 last edited by
              #6

              OK I found that it's unresolved bug related to decltype generally, not limited to lambda case.

              https://bugreports.qt.io/browse/QTCREATORBUG-13726

              As workaround, I would declare as the wordy type in example to avoid the problem.
              I've heard that Clang code model complete is very slow, but I haven't really tried it.

              Thanks for reply, sierdzio.

              BTW, is that I need to register another account for bugreport only? Separate from forum account?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sierdzio
                Moderators
                wrote on 23 Jun 2015, 05:48 last edited by
                #7

                @blazar said:

                BTW, is that I need to register another account for bugreport only? Separate from forum account?

                I'm not sure what is the current status. Previously, you needed separate accounts for pretty much all Qt services (Qt Account, forum account, JIRA account, etc.). The plan is to unify all those logins under a single one (Qt Account). This is already done for the forum, but seemingly the bugtracker is not there yet. If you want to know more, Tero Kojo probably has detailed information, he is one of the admins and is employed by Qt Company to update the various web services, as far as I am aware.

                (Z(:^

                1 Reply Last reply
                0

                3/7

                22 Jun 2015, 13:54

                • Login

                • Login or register to search.
                3 out of 7
                • First post
                  3/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved