>> Is there any reason why the AutoPtr class does not have a copy
>> constructor? I would like to create an stl vector of AutoPtr
>>
>> vector< AutoPtr<NumericVector<Number> > > local_solution_history;
>>
>> to store the entire solution history.
>
> Unfortunately you can never ever have a container of AutoPtrs. You
> might try a boost::shared_ptr instead. The reasoning is that items in
> an STL container must by copyable, and AutoPtr is not, since it's not
> clear which copy would then manage the memory.
See this for more info:
http://www.devx.com/tips/Tip/13606
Note that there was once upon a time a broken AIX compiler which did not
like its own std::auto_ptr<>, which is why we have AutoPtr<>. Make no
mistake, though, AutoPtr<> is exactly a std::auto_ptr<>. In fact, we took
the std::auto_ptr<> source from gcc's libstdc++ several years back and
renamed it. (This is permitted by the licensing of the file.)
I am pretty sure we could go back to std::auto_ptr<> now, but I'm not in a
big hurry either.
-Ben
|