template
vector& getValues(multimap& multi, Key& key)
{
typedef multimap::iterator imm;
static vector vect;
static struct
{
void operator()(const pair& p) const
{
vect.push_back(p.second);
}
} Push;
vect.clear();
pair range = multi.equal_range(key);
for_each(range.first, range.second, Push);
return vect;
}
This is a bit contrived because of your 'no loop' requirement.
I prefer:
template
vector getValues(multimap& map, Key& key)
{
vector result;
typedef multimap::iterator imm;
pair range = map.equal_range(key);
for (imm i = range.first; i != range.second; ++i)
result.push_back(i->second);
return result;
}