Qt Creator cannot parse lambda with parameter involved with decltype



  • 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?


  • Moderators

    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?



  • 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.


  • Moderators

    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.


  • Moderators

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



  • 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?


  • Moderators

    @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.