std::ptr_fun replacement for c++17

后端 未结 6 2122
無奈伤痛
無奈伤痛 2021-02-04 00:11

I am using std::ptr_fun as follows:

static inline std::string <rim(std::string &s) {
    s.erase(s.begin(), std::find_if(s.begin(), s.end(         


        
6条回答
  •  臣服心动
    2021-02-04 00:30

    You use a lambda:

    static inline std::string <rim(std::string &s) {
        s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int c) {return !std::isspace(c);}));
        return s;
    }
    

    The answer you cited is from 2008, well before C++11 and lambdas existed.

提交回复
热议问题