std::ptr_fun replacement for c++17

后端 未结 6 2127
無奈伤痛
無奈伤痛 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条回答
  •  -上瘾入骨i
    2021-02-04 00:48

    You use Lambda as suggested by Nicol Bolas but you can use auto and type will be deduced there, as follow:-

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

提交回复
热议问题