std::vector of references
There are some possibilities: Store a vector of pointers (use if your vectors share ownership of the pointers): std::vector<std::shared_ptr<Foo>> vA, vB; Store a vector of wrapped references (use if the vectors do not share ownership of the pointers, and you know the object referenced are valid past the lifetime of the vectors): std::vector<std::reference_wrapper<Foo>> vA, vB; … Read more