Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autoptrs in parameters

Status
Not open for further replies.

xwb

Programmer
Jul 11, 2002
6,828
GB
I came across this definition yesterday
Code:
  // 6.15
   void
      attributesInScope
      (ObjectInstanceHandle const & theObject,
      [COLOR=red]std::auto_ptr< AttributeHandleSet > theAttributes[/color])
      throw (RTI::ObjectInstanceNotKnown,
         RTI::AttributeNotRecognized,
         RTI::AttributeNotSubscribed,
         RTI::FederateInternalError);
I've never seen an auto_ptr as a parameter before. I started wondering: what exactly does this mean? Does it mean that the called routine can use the contents but should not take a copy of the pointer.
 
It means ownership of the object is passed to function, so when the function is completed the memory is destroyed.

The calling function should not be using that AttributeHandleSet after calling the function.
 
Thanks for the explanation - I found an MS example in the help on Visual Studio which used the auto_ptr in a similar way but there was no explanation in MS help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top