471,110 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,110 software developers and data experts.

STL container of auto_ptr

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
2 1442
* 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

"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.

Similar topics

5 posts views Thread by gg | last post: by
10 posts views Thread by dragoncoder | last post: by
9 posts views Thread by dragoncoder | last post: by
39 posts views Thread by Andre Siqueira | last post: by
18 posts views Thread by tech | last post: by
7 posts views Thread by tradevol | last post: by
17 posts views Thread by Ankur Arora | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.