Menu

Syntax Error for c++17 code

2017-11-08
2017-11-08
  • Martin Brieg

    Martin Brieg - 2017-11-08

    running the following code in the online demo with 1.81 returns syntax error

    #include <vector>
    #include <string>
    
    template <class ContainerT, class KeyGetter>
    std::wstring ConcatenateKeyStrings(ContainerT && cont, KeyGetter getKey)
    {
      std::wstring resultStr;
      for (auto const & obj : cont) {
        using ToStrFunReturnType = decltype(getKey(obj));
        if constexpr (std::is_same_v<ToStrFunReturnType, int>
          || std::is_same_v<ToStrFunReturnType, unsigned>
          || std::is_same_v<ToStrFunReturnType, size_t>
          || std::is_same_v<ToStrFunReturnType, int64_t>
          ) {
          resultStr += std::to_wstring(getKey(obj));
        }
        else {
          resultStr += getKey(obj);
        }
      }
      return resultStr;
    }
    
    void Test()
    {
      std::vector<int> ints = {1,2,3,4,5,42};
      std::wstring str = ConcatenateKeyStrings(ints, [](int i) -> int{ return i; });
    }
    

    Is there any estimate when c++17 will be supported? I know this is a lot to ask for.

    In the meantime, would it be possible to optionally just ignore statements containing c++17 code, so that cppcheck works for majority of the code base not using c++17 features? The tool is very usefull and i dont want to work without it.

     
  • Daniel Marjamäki

    Sorry I have no estimate. I would like to somehow ignore these until we handle it fully so it will be possible to analyze c++17 code asap.

    could you open some tickets for c++17 features that we need to add?
    http://trac.cppcheck.net

    if you need a trac account, send me your htpasswd hash and I will create an account for you. A simple method to generate the htpasswd hash is to use this webpage: http://www.htaccesstools.com/htpasswd-generator/

     

    Last edit: Daniel Marjamäki 2017-11-11

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.