Is this behaviour guaranteed all the time ? The code below creates a char* pointer using temporary unique_ptr. I thought the unique_ptr should get destructed at the end of the statement. To my surprise, the char* still points to valid memory.
void Fill(char* str, long len)
{
for(int i = 0; i < len; ++i)
str[i] = 'a';
}
char* x = std::unique_ptr<char[]>(new char[100]).get();
Fill(x, 100);
std::cout << x << std::endl;