Skip to content

Instantly share code, notes, and snippets.

@alexpana
Last active December 20, 2015 19:51
Show Gist options
  • Save alexpana/5d0faaa4217a7a91b6e8 to your computer and use it in GitHub Desktop.
Save alexpana/5d0faaa4217a7a91b6e8 to your computer and use it in GitHub Desktop.
#include <memory>
#include <vector>
using namespace std;
class Test {
public:
// vector of unique pointers to int
vector<unique_ptr<int>> intVector;
// moves a unique pointer into the vector
void addInt(unique_ptr<int>&& ptr) {
intVector.push_back(ptr);
}
};
int main() {
Test t1;
t1.addInt(make_unique<int>(-1));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment