The obvious answer is to use a custom dispenser, however you may find that it is really quite a difficult decision for what you need. If you want to do this, the easiest way is to make the selection (as an argument to the default template template for the vector <>) an implementation, copy it and make it work as needed.
Another solution may be to determine the specialized specialization of the vector, determine as many of the interface as possible, and implement memory settings.
Finally, what about defining your own container with the appropriate STL interface, defining random access iterators, etc. This can be quite easy, given that the base array will display the vector <> well, and the pointers to it will be displayed in iterators.
UPDATE comment: "Is there a way to build std :: vector using the given fragment of the T * array of allocated memory and the size of this memory?"
Of course, the simple answer here is "No." If you want the result to be a vector <>, then it should support growth as necessary, for example, using the reserve () method, and this is not possible for a given fixed distribution. So, the real question really is: what exactly do you want to achieve? Something that can be used as a vector <> or something that really has a sense in a certain sense, a vector, and if so, what is the point?
Keith
source share