Consider the following code in C++/CX:
std::shared_ptr<int> a(new int(9));
int cnt = a.use_count(); // == 1
{
auto ppp = ref new AsyncActionCompletedHandler(
[a](IAsyncAction^ asyncInfo)
{
});
cnt = a.use_count(); // == 2
}
cnt = a.use_count(); // still == 2 !!!
Is this a bug ?
Note that it's C++/CX, no GC here, so 'ppp' is destroyed on scope exit, however, 'a's destructor not run...