STL containers with reference to objects [duplicate]
If you know what you’re doing, you can make a vector of references using std::reference_wrapper: #include <functional> #include <vector> int main() { std::vector<std::reference_wrapper<int>> iv; int a = 12; iv.push_back(a); // or std::ref(a) // now iv = { 12 }; a = 13; // now iv = { 13 }; } Note of course that any … Read more