简体   繁体   English

56:68:错误:预期表达

[英]56:68: error: expected expression

I am trying to understand the last argument of find_if which is giving compilation errors. 我试图了解find_if的最后一个参数,它给出了编译错误。 Any pointers on documentation in the context of this problem on the usage of [](int ch) will be really helpful. 在使用[](int ch)解决此问题的上下文中,任何有关文档的指针都将非常有帮助。 http://en.cppreference.com/w/cpp/algorithm/find http://en.cppreference.com/w/cpp/algorithm/find

Seeing compilation error with one of the argument. 使用以下参数之一看到编译错误。

https://leetcode.com/playground/U5SLW8zq https://leetcode.com/playground/U5SLW8zq

median.cpp:56:68: error: expected expression input.erase(input.begin(), find_if(input.begin(), input.end(), [](int ch) { ^ median.cpp:62:55: error: expected expression input.erase(find_if(input.rbegin(), input.rend(), [](int ch) { 中位数.cpp:56:68:错误:预期表达式input.erase(input.begin(),find_if(input.begin(),input.end(),[](int ch){^中位数.cpp:62: 55:错误:预期表达式input.erase(find_if(input.rbegin(),input.rend(),[](int ch){

void trimLeftTrailingSpaces(string &input) {
    input.erase(input.begin(), find_if(input.begin(), input.end(), [](int ch) {
        return !isspace(ch);
    }));
}

void trimRightTrailingSpaces(string &input) {
    input.erase(find_if(input.rbegin(), input.rend(), [](int ch) {
        return !isspace(ch);
    }).base(), input.end());
}

The issue was due to the missing compiler option. 问题是由于缺少编译器选项。 I could compile using c++11 我可以使用c ++ 11进行编译

$ g++ -std=c++11 median.cpp $ g ++ -std = c ++ 11平均.cpp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM