I have a class like this :
class Foo
{
public:
Foo()
{
for(int i = 0; i < 10; ++i)
v.push_back(i);
};
const vector<
Overload resolution does not take member accessibility into account, so an ideal overload candidate is chosen and then member accessibility is checked to see if the call is legal.
The realistic workaround is:
Foo foo;
Foo const& foo_alias = foo;
for (std::size_t i = 0; i != foo_alias.V().size(); ++i)
cout << foo_alias.V().at(i) << endl;