47 minutes ago, jalfd wrote
Most of the time, you can/should use something like unique_ptr, which is, well, optimal. There is literally no overhead to using it.
How does unique_ptr work? Why do you have to use the move function when assigning 1 unique_ptr to another?
unique_ptr<wstring> pMsg(new wstring) ; *pMsg = L"The unique_ptr class supersedes auto_ptr" ; ::OutputDebugString(pMsg->c_str( )) ;// auto pMsg3 = pMsg ; // compile error. auto pMsg3 = move(pMsg) ; ::OutputDebugString(pMsg3->c_str( )) ;
and how to build a collection of unique_ptr?
vector<unique_ptr<wstring>> msgList; msgList.push_back(pMsg3) ; // compile error.
http://msdn.microsoft.com/en-us/library/dd293668.aspx
http://msdn.microsoft.com/en-us/library/ee410601.aspx#2