Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I have this code :

EcosiaSearcher.h
C++
template <typename T, typename M>
	list<T> WINAPI do_search(string research, string parameters, void (M::*parse)(char* , list<T> &));


EcosiaSearcher.cpp
C++
template <typename T, typename M>
list<T> WINAPI EcosiaSearcher::do_search(string research, string parameters, void (M::*parse)(char*, list<T> &))
{
	...
	list<T> results;

	...

	parse((char*)r_buffer, results);

	...

	return results;
}

template list<EcosiaWebResult> WINAPI EcosiaSearcher::do_search(string research, string parameters, void (EcosiaWebHtmlParser::*parse)(char*, list<EcosiaWebResult> &));


And i try to call the function like this :

C++
return EcosiaSearcher::do_search<EcosiaWebResult>(research, parameters, _web_parser.parse);


Here is the signature of the function i want to point :

C++
void WINAPI parse(char* sz_buffer, list<EcosiaWebResult> &ls);


It doesn't work. I have this error :

C#
Severity	Code	Description	Project	File	Line	Suppression State
Error	C3867	'EcosiaWebHtmlParser::parse': non-standard syntax; use '&' to create a pointer to member	Ecosiana	d:\users\deckbsd\source\projects\ecosiana\ecosiana\ecosiawebsearcher.cpp	17	


Thanks in advance for your time and answers :)

What I have tried:

I also tried :

return EcosiaSearcher::do_search<ecosiawebresult>(research, parameters, &EcosiaWebHtmlParser::parse);

...
Posted
Updated 2-Jun-16 21:01pm
v2
Comments
nv3 30-May-16 11:12am    
And what was the error message on your second attempt, the one with the '&'?
Philippe Mori 2-Jun-16 15:12pm    
C++ is not C#... If you use pointer to member function, then you need to save both the object and the member address. You cannot convert member function to free function or vice versa. However, using function object can help hide some details.

It is clearly an error which the compiler detect and it yells also how to fix it.

Googling after the Error C3867 and there is explained some details to the syntax.

Because your function with global scopeI would use:
C++
do_search(research, parameters, &parse);
 
Share this answer
 
Thanks all for your replies :)

Exactly C++ is not C# i did it correctly :


C++
template <typename typename="" m="">
list<t> WINAPI EcosiaSearcher::do_search(string research, string parameters, string page, M& parser, void (M::*parse)(char*, list<t> &))

</t></t></typename>

C++
(parser.*parse)((char*)r_buffer, results);


C++
template list<ecosiavideoresult> WINAPI EcosiaSearcher::do_search(string research, string parameters, string page, EcosiaVideoHtmlParser &parser, void (EcosiaVideoHtmlParser::*parse)(char*, list<ecosiavideoresult> &));
</ecosiavideoresult></ecosiavideoresult>


and the call :

C++
return EcosiaSearcher::do_search<ecosiawebresult>(research, parameters, ECOSIA_SEARCH_PAGE, _web_parser, &EcosiaWebHtmlParser::parse);
</ecosiawebresult>


best regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900