$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] Safe to pass dereferenced anonymous shared_ptr?
From: Chris Stankevitz (chrisstankevitz_at_[hidden])
Date: 2013-11-05 18:12:54
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 <boost/make_shared.hpp>
void f(const int& i)
{
std::cout << "i = " << i << std::endl;
}
int main()
{
f(*boost::make_shared<int>(42));
return 0;
}