J
Jason Sachs
In the function copy_info below, which happens first:
(a) X gets copied
(b) Y's destructor is called
class T
{
X m_info;
L m_semaphore;
public:
X copy_info();
}
X T::copy_info()
{
Y ylock(m_semaphore);
return m_info;
}
and if Y's destructor happens first, is there any way to reverse the
order besides a brute force extra copy:
X T::copy_info()
{
Y ylock(m_semaphore);
X stupid_temporary(m_info);
return stupid_temporary;
}
(a) X gets copied
(b) Y's destructor is called
class T
{
X m_info;
L m_semaphore;
public:
X copy_info();
}
X T::copy_info()
{
Y ylock(m_semaphore);
return m_info;
}
and if Y's destructor happens first, is there any way to reverse the
order besides a brute force extra copy:
X T::copy_info()
{
Y ylock(m_semaphore);
X stupid_temporary(m_info);
return stupid_temporary;
}