I was wondering if there is a way to create a template function which takes a reference to ANY collection of a specific type. i.e. something like:

```
class Bob
{
  public:
  int age;
  int height;
}

template<class T>
void functionWhichIteratesOverBobs(T &bobs)
{
    int totalAge = 0;
    for(auto &bob: bobs)
    {
         totalAge += bob.age;
    }
}

```

Basically is there a way to, in the definition of the template function, require that T have a begin() and end() function which return an iterator to T.

I've seen the following question, but that would require a function which takes a begin and end, i.e.

```
std::vector<Bob> bobs;
functionWhichIteratesOverBobs(bob.begin(), bob.end());

```

when what I would like is:

```
std::vector<Bob> bobs;
functionWhichIteratesOverBobs(bobs);

```

[Function that takes an STL iterator over ANY container of a elements of a specific type](https://stackoverflow.com/questions/4354665/function-that-takes-an-stl-iterator-over-any-container-of-a-elements-of-a-specif)