Skip to content

Instantly share code, notes, and snippets.

@c4tachan
Created March 24, 2015 12:43
Show Gist options
  • Save c4tachan/baa16976162a72c00c45 to your computer and use it in GitHub Desktop.
Save c4tachan/baa16976162a72c00c45 to your computer and use it in GitHub Desktop.
typedef struct hasSmrtPtr
{
vector<unique_pointer<int>> unq;
} hsSmrtPtr;
hsSmrtPtr g;
void smrtPtrScope(int len)
{
for(int i = 0; i < len; ++i)
{
g.unq.resize(g.size() + 1);
int* tmpPtr;
*tmpPtr = i;
g.unq.back().reset(tmpPtr);
}
}
void main()
{
smrtPtrScope(5);
for(auto i : g.unq)
{
std::cout << *(g.unq) << std::endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment