
6 Nov
2013
6 Nov
'13
2:43 a.m.
On 11/5/2013 6:12 PM, Chris Stankevitz wrote:
Q1: Is the below code dangerous? A1: Only if the anonymous shared_ptr is deleted before function f returns.
Q2: Is the anonymous shared_ptr deleted before function f returns? A2: ?
Thank you,
Chris
===
#include <iostream> #include
void f(const int& i) { std::cout << "i = " << i << std::endl; }
int main() { f(*boost::make_shared<int>(42));
return 0; }
A2: No. But this is C++ and has nothing to do with shared_ptr.