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 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate 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 #49413 is a reply to message #49408] |
Tue, 06 February 2018 16:31 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 06 February 2018 03:37Thanks, 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
|
|
|
|
Goto Forum:
Current Time: Thu Apr 18 03:54:47 CEST 2024
Total time taken to generate the page: 0.01763 seconds
|