c++ - How to iterate through such a map? How to fix 8 scary C2784 errors? -



c++ - How to iterate through such a map? How to fix 8 scary C2784 errors? -

so seek compile such code:

bool server_utils::find_service_by_name_iterator_function(std::pair<boost::shared_ptr<service>, server_utils::service_description> const & element, std::string name) const { homecoming element.second.name == name; } server_utils::service_description server_utils::stop_service_by_name(std::string name) { typedef std::map<boost::shared_ptr<service>, server_utils::service_description> map_t; map_t::iterator map_it = std::find_if(description.service_map.begin(), description.service_map.end(), std::bind1st(std::ptr_fun(&server_utils::find_service_by_name_iterator_function), name)); if (map_it != description.service_map.end()) { description.service_map.erase (map_it); } else { throw std::runtime_error("service such name not found map not found!"); } }

where

struct service_description { //a service must have std::string name; std::string library_name; std::string class_name; std::string root_file_system_directory; boost::property_tree::ptree service_custome_properties_tree; //a service might have std::vector<std::string> set_of_url_rules; boost::unordered_multimap<std::string, std::string> set_of_header_rules; boost::unordered_multimap<std::string, std::string> set_of_arguments_rules; std::set<std::string> url_extensions; std::string root_service_web_path; };

but unusual errors:

error c2784: 'std::pointer_to_binary_function<_arg1,_arg2,_result,_result(__cdecl *)(_arg1,_arg2)> std::ptr_fun(_result (__cdecl *)(_arg1,_arg2))' : not deduce template argument '_result (__cdecl *)(_arg1,_arg2)' 'bool (__thiscall server_utils::* )(const std::pair<_ty1,_ty2> &,std::string) const' error c2784: 'std::pointer_to_binary_function<_arg1,_arg2,_result,_result(__fastcall *)(_arg1,_arg2)> std::ptr_fun(_result (__fastcall *)(_arg1,_arg2))' : not deduce template argument '_result (__fastcall *)(_arg1,_arg2)' 'bool (__thiscall server_utils::* )(const std::pair<_ty1,_ty2> &,std::string) const' error c2784: 'std::pointer_to_unary_function<_arg,_result,_result(__cdecl *)(_arg)> std::ptr_fun(_result (__cdecl *)(_arg))' : not deduce template argument '_result (__cdecl *)(_arg)' 'bool (__thiscall server_utils::* )(const std::pair<_ty1,_ty2> &,std::string) const' error c2784: 'std::pointer_to_unary_function<_arg,_result,_result(__stdcall *)(_arg)> std::ptr_fun(_result (__stdcall *)(_arg))' : not deduce template argument '_result (__stdcall *)(_arg)' 'bool (__thiscall server_utils::* )(const std::pair<_ty1,_ty2> &,std::string) const' , on...

what shall do? how prepare code? can boost.function or boost.bind help me?

use boost::bind; it's far smarter:

map_t::iterator map_it = std::find_if( description.service_map.begin(), description.service_map.end(), boost::bind(&server_utils::find_service_by_name_iterator_function, this, name));

c++ visual-studio map iterator std

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -