How to use a function of own class in for_each method?

前端 未结 3 1048
太阳男子
太阳男子 2021-01-07 05:21

Assume I have this class (inherited from std::Vector, it\'s just an example)

#include 

using namespace std;

template 
class C          


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-07 05:58

    You need to bind the this pointer:

    public:   
    void method() 
    {
        for_each(this->begin(), this->end(), bind(&C::transformation, this, placeholders::_1));
    }
    

提交回复
热议问题