By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

STL container of auto_ptr

P: n/a
my version of the STL has the following documentation:

You can pass an auto_ptr<Type> object by value as an argument to a function
call. You can return such an object by value as well. Both operations depend
on the implicit construction of intermediate objects of class
auto_ptr<Type>::auto_ptr_ref<Other>, by various subtle conversion rules. You
cannot, however, reliably manage a sequence of auto_ptr<Type> objects with a
Standard Template Library container.

Is this restriction against having, say, a vector of auto_ptr normal? If
so, why?
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* Boston:

Is this restriction against having, say, a vector of auto_ptr normal?
It's in the standard, if that's what you're asking.

If so, why?


Technically because a std:.atuo_ptr is not a copyable object. Standard
containers require copyable objects. They copy things around.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #2

P: n/a

"Alf P. Steinbach" <al***@start.no> wrote in message
news:41****************@news.individual.net...
* Boston:

Is this restriction against having, say, a vector of auto_ptr normal?


It's in the standard, if that's what you're asking.

If so, why?


Technically because a std:.atuo_ptr is not a copyable object. Standard
containers require copyable objects. They copy things around.


Ah, because if you copy the auto_ptr, the source sets its ptr to NULL,
therefore it couldn't be const&. I understand now, thanks.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.