vendredi 26 août 2016

How to use std::bind with std::function and std::map

I am trying to create a map of std::function and then trying to bind it few parameters, but it is giving an error. So, my std::function definition is

using abc = std::function<double(const double& t1, const double& t2)>;

and the map is

std::map<std::pair<std::string, std::string>, abc> conversion_;

The way I am trying to insert in this map is

conversion_.emplace(
            std::make_pair("a", "b"),
            std::bind(conversion, 3, std::placeholders::_1));

conversion_.find(std::make_pair("a", "b"))->second(4); -- Access

I have defined the function conversion, but when I am trying to access the function it is giving the below error

 error: no match for call to ‘(const std::function<double(const double&, const double&)>) (int)’

Aucun commentaire:

Enregistrer un commentaire