From: Jozef M. <mis...@ho...> - 2009-07-22 17:54:07
|
----------------------------------------> Date: Wed, 22 Jul 2009 16:22:01 +0200> From: ms...@gm...> To: mis...@ho...> CC: pdf...@li...> Subject: Re: why {CArray,CDict}::addProperty doesn't take shared_ptr>> On Wed, Jul 22, 2009 at 02:06:48PM +0000, Jozef Misutka wrote:>>>>>>>> ---------------------------------------->>> Date: Wed, 22 Jul 2009 15:13:30 +0200>>> From: ms...@gm...>>> To: mis...@ho...>>> CC: pdf...@li...>>> Subject: why {CArray,CDict}::addProperty doesn't take shared_ptr>>>>>> Hi Jozo,>>> I am just writing some code and need to add an existing property to an>>> array. I am wondering why does this interface takes IProperty& rather>>> than shared_ptr as the value parameter?>>>> the question is, why should it take a ptr?>> Because we are working with the ptr everywher? Consider simple example:there is basic rule i adhere to and that is use & instead of ptr when the value must exist. you add complexity otherwise.>> shared_ptr array;>> I would like:> array->addProperty(differentArray->getProperty(1));>> I have to:> array->addProperty(*differentArray->getProperty(1));in yours i can do invalid things likearray->addProperty(shared_ptr());>> or consider new element adding> array->addProperty(*shared_ptr(CStringFactory::getInstance()));array->addProperty(CString());/jozo>> This sounds little bit asymmetric and I don't see any reason for it.> This question is not a call for change, I just don't understand it.> Maybe we should reconsider during API cleanup?>>>>> /jozo>>>>>>>> -->>> Michal Hocko>> --> Michal Hocko _________________________________________________________________ Windows Live™ Hotmail®: Search, add, and share the web’s latest sports videos. Check it out. http://www.windowslive.com/Online/Hotmail/Campaign/QuickAdd?ocid=TXT_TAGLM_WL_QA_HM_sports_videos_072009&cat=sports |