and I am using it for sorting a vector on the basis of time
std::sort(vecT1->begin(), vecT1->end(), compr);
it is giving me an error which is as follows
error: argument of type ‘bool (class1::)(const class1::structT1&, const class1::structT1&)’ does not match ‘bool (class1::*)(const class1::structT1&, const class1::structT1&)’
I have removed the class1 where you suggested but now it is giving me another error
1 2 3 4 5 6 7
class1.cpp:63: error: ISO C++ forbids declaration of ‘structT1’ with no type
class1.cpp:63: error: expected ‘,’ or ‘...’ before ‘&’ token
class1.cpp: In function ‘bool compr(int)’:
class1.cpp:65: error: ‘t1’ was not declared in this scope
class1.cpp:65: error: ‘t2’ was not declared in this scope
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.4/../../../../include/c++/4.4.4/algorithm:62,
from class1.cpp:6:
ok the function is static. That changes the situation so then don't remove remove 'class1::' before compr instead write std::sort(vecT1->begin(), vecT1->end(), &compr); // note that '&'
I want to find out all the matches (could be more than two) between itFirst and itCurrent i-e all matches in the vector my_file_as_blocks. Could you please tell me how/where do I increment/change_value_of the itFirst? OR how/where do I match each value of itCurrent with itFirst?
well instead of having a single iterator itFirst you need a vector of iterators (say matched_vector).
Change line 13 to if(std::find(matched_vector.begin(), matched_vector.end(), itCurrent) == matched_vector.end()) (that tells you that itCurrent has no match)
you need a second loop before line 16 that iterates everything from itCurrent + 1 to end
Store all iterators accordingly (before line 18 matched_vector.push_back(itCurrent)).