I have this question because I am reading the section for auto_ptr
. It says auto_ptr
cannot be saved in a vector because of its destructive copy and assignment. I can understand it somehow and one example I can think of is something like auto_ptr ap = vec[0]
will surprise me. But what if I use it cautiously and do not do this, can I store auto_ptr
in a vector? Is there any deeper reason why I cannot store? Maybe the implementation of vector internally needs this assumption that elements need to be copy constructable?
Thanks.