int plugin::feature(const InstanceInput &input) {
auto parse_word=[](const string input_text){
string text = input_text;
int i=text.find("%");
if(i!=-1){
return text.substr(0, i);
}
return "";
};
....
}
I am in Clion and it displays an error message at the 'return' statement saying that:
return type const char* must match previous return type std:basic_string<char> when lambda expression has unspecified specific return type
How to fix this?
CodePudding user response:
Instead of:
if(i!=-1){
return text.substr(0, i);
}
return "";
Try
if(i!=-1){
return text.substr(0, i);
}
return std::string();
auto return type for your lamda has been determined as string in the first case, and as char* in the second, which is a mismatch.
