`f` will be released after this function ends, since the `RCP` in the line `RCP<Integer> f` above goes out of scope, so it will deallocate the Integer in `f`. I guess as you wrote it, it might still work, since it will copy the actual instance and create a new class Integer in the vector. But the standard way to do that is to use `std::vector<RCP<Integer>>` and just do:
```
primes.push_back(f);
```
This is reasonably fast, since only a tiny class `RCP` is being created and it increases the reference count to just one `Integer` instance. The approach that you used might work, but I would avoid it.