|
-
June 24th, 2010, 03:08 PM
#13
Re: Why does std::vector require its elements to be assignable?
 Originally Posted by kempofighter
All sequence containers have the same requirement that the type used to instantiate the template be copyable and assignable. This is a common requirement for them all. Therefore using a stack (which uses a deque by default) might not help depending on your implementation. In my case I get lucky because deque's push_back implementation is totally different then vector's. I poked around a little more and I found out that my vector:  ush_back function is implemented in terms of the insert member function which is rather complex. As I digged deeper I found out that it has to do with dependencies on some of the other internal member functions of the vector. Although a push_back could be very simple in some cases the fact that those dependencies on other functions exist mean that they have to be completely compiled. Along the way one of those functions that has to be compiled happens to invoke operator=.
Right - now we're getting to the heart of the matter.
What I really want to know is, is it possible to implement vector in a way that certain operations can be performed without the requirement of assignability?
I suspect the answer is yes, and if so, the next question that naturally arises is, why doesn't the standard mandate such an implementation?
Old Unix programmers never die, they just mv to /dev/null
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|