Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Bug with FindMatch(const Range& r, const C& match, int from = 0)
Bug with FindMatch(const Range& r, const C& match, int from = 0) [message #49407] Tue, 06 February 2018 05:00 Go to next message
Novo is currently offline  Novo
Messages: 878
Registered: December 2006
Experienced Contributor
This method should look like below.
template <class Range, class C>
int FindMatch(const Range& r, const C& match, int from = 0)
{
	for(int i = from; i < r.GetCount(); i++)
		if(match(r[i])) return i;
	return -1;
}

Template parameter class V is redundant. It doesn't allow to deduct types from arguments.


Regards,
Novo
Re: Bug with FindMatch(const Range& r, const C& match, int from = 0) [message #49408 is a reply to message #49407] Tue, 06 February 2018 09:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
Thanks, fixed.

Anyway, I am intrigued why this was not causing problems? FindMatch is used in FindIndex and that one is used quite intensely, so e.g. theide should not compile...

What compiler are you using?

Mirek
Re: Bug with FindMatch(const Range& r, const C& match, int from = 0) [message #49413 is a reply to message #49408] Tue, 06 February 2018 16:31 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 878
Registered: December 2006
Experienced Contributor
mirek wrote on Tue, 06 February 2018 03:37
Thanks, fixed.

Anyway, I am intrigued why this was not causing problems? FindMatch is used in FindIndex and that one is used quite intensely, so e.g. theide should not compile...

What compiler are you using?

Mirek

gcc 7.2.0

FindIndex looks like below.
template <class Range, class V>
int FindIndex(const Range& r, const V& value, int from = 0)
{
	for(int i = from; i < r.GetCount(); i++)
		if(r[i] == value) return i;
	return -1;
}

FindMatch is not used there.
Actually, I couldn't find even a single use of FindMatch in Upp ...


Regards,
Novo
Re: Bug with FindMatch(const Range& r, const C& match, int from = 0) [message #49414 is a reply to message #49413] Tue, 06 February 2018 17:17 Go to previous message
mirek is currently offline  mirek
Messages: 11991
Registered: November 2005
Ultimate Member
I see, correct. I have mistaken it with CoFindMatch....
Previous Topic: Core/SSL crashes at exit on Linux.
Next Topic: Problem with websocket connect method
Goto Forum:
  


Current Time: Sun Aug 18 07:44:41 CEST 2019

Total time taken to generate the page: 0.00656 seconds