What's wrong with placing vector on stack?
But it can "allocate" wherever you put it. Of course you must be careful with correctly initializing/freeing it with placement new/delete:
| typedef std::vector<int> I;
void f()
{
I i; // on stack
I* s = new I(); // s->i is on heap
char* buffer = ... ; // get buffer from somewhere
I* i = new (buffer) int I(); // put it in buffer, wherever it is, and initialize
}
|
If you put vector in some structure, and override new/delete operators of this structure, then you can place structure in wherever allocator you want as long new/delete of this structure initializes vector. Typically this is what you want. Because you want to keep members of structure together.