find a range

Joined
Oct 9, 2009
Messages
9
Reaction score
0
Hi all
do you know a nice way to find a range of elements in containers to retrieve a range of values as a std::pair according to some custom predicate?
I would like to have something like the example below

typedef std::vector< int > v;
typedef std::vector< int >::iterator vit;

int values[] = { 1,2,3,4,5,6,7,8,9,10}
v vct( values, values+10);

std::pair< vit,vit > res = get_range( vct.begin(), vct.end(), MYPREDICATE );

I saw std::equal_range but this looks for equality. Suppose I want to find
all values that are greater>2 and lower <6 and print all of those what can I do?
Thanks for your help.
CS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top