How can I add a shared_ptr to a container of shared_ptrs of some existing object?
Example of what I'm trying to accomplish here:
Code:#include <algorithm> #include <iostream> #include <memory> #include <vector> class Foo{}; int main() { std::vector<Foo> foos; foos.push_back(Foo()); foos.push_back(Foo()); foos.push_back(Foo()); std::vector<std::tr1::shared_ptr<Foo>> fooPointers; std::for_each ( foos.begin(), foos.end(), [&fooPointers](Foo foo) { fooPointers.push_back( /* How do I add an existing foo as a shared_ptr here? */ ); } ); return 0; }