
Am Friday 14 August 2009 00:24:54 schrieb Mathias Gaunard:
the vector operates on the stack as long as there is enough space, and moves to the heap afterwards. in most cases there is no dynamic allocation.
An implementation is free to consider any instance of an allocator with the same arguments passed to the constructor as equal, IIRC.
Does your allocator suffer from this issue?
I don't think so. the allocator doesn't have any state except a constant pointer to "buffer"(see exmaple above), so multiple copies of the same allocator can be used simultaniously. the only c++ standard requirement it can't fulfil is a default constructor. I'm not sure why that is needed though. but the standard says that Allocator() must be a valid expression.
Also, is the container still copyable properly?
yes. the only issue that might arise is that the buffer on the stack could go out of scope before the vector has, as a result of swap()ing the contents of the vector into another vector with a longer lifetime. but I don't think that's a violation of the standard because that is also true for other allocators, e.g. pool allocators. Am Friday 14 August 2009 00:00:37 schrieb Christian Schladetsch:
Two immediate issues are alignment and the fact that you are using a stateful allocator.
do you consider a constant pointer "stateful", and why is that a problem?