This causes my program to have an assertion failure:
int a = 5;
std::unique_ptr<int>intptr(&a);
The error
File: f:\dd\vctools\crt\crtw32\misc\dbgdel.cpp
Line: 32
Expression : _BLOCK_TYPE_IS_VALID(pHead > nBlockUse)
It works well when I initialise it using "new" or " = make_unique (..)" but I'm curious to know why I can't initialise it by giving the adress of an existing variable.
awas declared on the stack, you cannot delete it, which is what yourunique_ptrtries to do when it falls out of scope. - Cory Kramer