Поэтому я пытаюсь скомпилировать такой код:
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
{
return 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 with such name was not found map not found!");
}
}
, где
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;
};
Но я получаю странные ошибки:
error C2784: 'std::pointer_to_binary_function<_Arg1,_Arg2,_Result,_Result(__cdecl *)(_Arg1,_Arg2)> std::ptr_fun(_Result (__cdecl *)(_Arg1,_Arg2))' : could not deduce template argument for '_Result (__cdecl *)(_Arg1,_Arg2)' from '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))' : could not deduce template argument for '_Result (__fastcall *)(_Arg1,_Arg2)' from '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))' : could not deduce template argument for '_Result (__cdecl *)(_Arg)' from '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))' : could not deduce template argument for '_Result (__stdcall *)(_Arg)' from 'bool (__thiscall server_utils::* )(const std::pair<_Ty1,_Ty2> &,std::string) const'
and so on...
Что мне делать?Как исправить мой код?Могут ли мне помочь boost.function или boost.bind?