I have a container which is actually a std::shared_ptr< std::vector< Element > >. I wrapped this type into a MyVector class because I do not want people to mess the things up with the pointer:
class MyVector
{
std::shared_ptr< std::vector< Element > > m_vector;
};
I want to be able to use MyVector into a range-based for loop like this:
int main( )
{
MyVector vector;
// ...
for( const auto& element : vector )
{
// ...
}
return 0;
}
So now I have to redirect to the internal pointer the correct functions in order to make it work. To which C++ Concept must MyVector be compliant?
And how can I achieve the result that when the internal std::shared_ptr is nullptr, MyVector behaves exactly like an empty std::vector (so that it will not crash on a range-based loop, but will just make no iteration at all)?