Last active
December 20, 2015 19:51
-
-
Save alexpana/5d0faaa4217a7a91b6e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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