CLion indexer fails to find specific STL function

已回答

I just updated CLion and suddenly the indexer claims that there is "no matching function" to std::getline, called on a std::stringstream with a third argument for a delimiter. All other instances of std::getline are able to be resolved. In one case, it has three arguments but is called on a basic_stringstream, in another, it is called on a stringstream but is called without the delimiter argument. Only that specific call is showing an error. I have included <iostream>, <string>, <sstream>, the works. When I scrap my code and write a main() function that looks like

#include <sstream>
#include <iostream>

int main() {
std::string a = "a,b,c,dee";
std::stringstream ss(a);
std::string word;
std::getline(ss, word, ',');
}

it somehow also works, as opposed to

std::string word;
getline(datafile, line);
std::stringstream ss(line);
for (int j=0; j<d; j++) {
std::getline(ss, word, '\t'); //the sole line that gives an error
(*data)(j, i) = stoi(word);
}

This makes even less sense, since it's the exact same invocation with the exact same types involved. Regardless of any indexing errors, the code compiles and runs. Is the editor searching somewhere different for header files, and using a different version of the C++ standard library? How do I configure this?

my CMakeLists.txt is as follows. I am using the bundled version of CMake.

cmake_minimum_required(VERSION 3.8)
project(ExpectationMaximization)

set(CMAKE_CXX_STANDARD 11)

set(SOURCE_FILES main.cpp)
add_executable(ExpectationMaximization ${SOURCE_FILES})

EDIT: I just realized that the editor only shows an error if I use a backslash sequence to define the delimiter character. It seems like some kind of parsing bug. for example,

std::getline(ss, word, ',');

works, but

std::getline(ss, word, '\t');

shows an error. Everything points to this being a bug, but if someone knows what might be causing it, please tell me.

1

Hi, Jamesn8, thanks for the investigation!

I've created the issue in our tracker, please follow it to get updates: https://youtrack.jetbrains.com/issue/CPP-11823.

Small note: I was able to reproduce the issue only with clang; with gcc there is no "No matching function" error. 

0

The same thing is happening for me, just with std::map and std::list methods. Syntax highlighting indicates "No matching function" but the code compiles and runs no problem.

1

@Maya, could you please try CLion 2018.1.1 EAP? If the issue is still actual in it, please provide a simple sample code to reproduce the issue.

 

1

Anna, it's fixed in CLion 2018.1.1 EAP. Thanks!

1

请先登录再写评论。