// A と Bのところだけが異なるfとf2
// うまくこの関数をまとめれませんか?

#include <iostream>
#include <vector>
#include <algorithm>

struct Foo
{
void Func() const
{}
};

void f(const std::vector<Foo>& vf)
{
std::for_each(vf.begin(),vf.end(),
[](auto&& f)
{
f.Func();//A
}
);
}

void f2(const std::vector<Foo*>& vf)
{
std::for_each(vf.begin(),vf.end(),
[](auto&& f)
{
f->Func();//B
}
);
}

int main( int argc, char *argv[] )
{
std::vector<Foo> vf;
std::vector<Foo*> vfp;

 f(vf);
 f2(vfp);
}