[LC++]STL and auto_ptr woes
Charles Randle
charlesrandle at hotmail.com
Thu Mar 7 01:18:10 UTC 2002
Hi All ,
I am using the STL to store pointers to objects which are expensive to copy
(hence the pointers.
I know it isn't a good idea to use the auto_ptr class with STL classes but I
don't readily remember why could anyone tell me why the following wouldn't
be a good idea ?
::std::map <
::std::string,::std::pair<auto_ptr<someobject1>,auto_ptr<someobject2> > >
bigMap;
Given that the above isn't a good idea I have the following:
::std::map < ::std::string , ::std::pair<someobject1 *,someobject2 *> >
BigMap2
However when I assign the pointers to an auto_ptr object as in:
::std::auto_ptr<someobject1> vb = BigMap2["located"].second.first;
the compiler gives the following error:
simple.cpp:52:conversion from 'someobject1*' to non-scalar type
'std::auto_ptr<someobject1>' requested
What is the reason for this error and what can I do to fix it ???
Best Regards,
Charles Randle
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
More information about the tuxCPProgramming
mailing list