samedi 30 juillet 2016

omit std::placeholders in std::bind

To create std::function, here is what I do:-

std::function<void(int,int,int)> f=
    std::bind(&B::fb,this,
        std::placeholders::_1,
        std::placeholders::_2,
        std::placeholders::_3
    );  

void B::fb(int x,int k,int j){} //example

It is obvious that B::fb receive three parameters.
To increase readability & maintainablity, I wish I could call this instead :-

std::function<void(int,int,int)> f=std::bind(&B::fb,this);  //omit _1 _2 _3

Question
Are there any features in C++ that enable omitting the placeholders?
It should call _1,_2, ..., in orders automatically.

I have googled "omit placeholders c++" but not find any clue.

Aucun commentaire:

Enregistrer un commentaire