
On Tue, Oct 30, 2012 at 10:16 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
Not really.
"no swap() function invalidates any references, pointers, or iterators referring to the elements of the containers being swapped." (C++11 23.2.1.10)
I don't know of any way to implement this with the small object optimization.
"Challenge accepted"? Well, depends what is meant by pointers and references. Actual pointers and references, or vector<>::pointer_type, etc? Because, at least for iterators, you could keep a list of outstanding iterators and update them during swap. Typically not a good idea, but possible. Same for pointer/reference if they only need to be pointer-like and reference-like. Also, I suppose my vector could have small object optimization until a pointer/reference was taken. Again, probably not a brilliant plan... Tony