2

我似乎有一个问题,qtcreator 没有自动完成我的代码,这很烦人。

目前,当我尝试在这样的 for 循环中使用结构绑定时,它无法自动完成。

std::vector<pair<string,AudioFile<double>>> list_of_files;
// Some init of list_of_file


for (const auto& [name,file]: this->list_of_files) // red line under this.. does seem to like structure bindings?
{
    file.printSummary(); // qtcreator don't offer any autocomplete options?

}

qtcreator 基本上抱怨上面发布的代码的所有内容..

但是当我这样写时:

for (int i = 0 ; i <list_of_file.size() ; i++) // No red lines under this.. 
{
  list_of_files[i].second.printSummary() // Autocompletes without any problems.
}

qtcreator 不会抱怨这段代码,而且似乎可以自动完成它。那么为什么它会导致 c++17 风格出现这么多问题呢?

对此有任何修复吗?

4

1 回答 1

0

对此的临时解决方案似乎是这样的 - 自动完成不会抱怨,并且似乎符合我对(可读性)的定义:

for ( const auto &elements : this->list_of_files)
{
   auto name = std::get<0>(elements);
   auto file = std::get<1>(elements);
}
于 2017-11-28T08:46:10.460 回答