Does STL Vector use 'new' and 'delete' for memory allocation by default?

前端 未结 5 1721
小鲜肉
小鲜肉 2021-02-08 14:57

I am working on a plugin for an application, where the memory should be allocated by the Application and keep track of it. Hence, memory handles should be obtained from the host

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 15:15

    std::vector uses the unitialized_* functions to construct its elements from raw memory (using placement new). It allocates storage using whatever allocator it was created with, and by default, that allocator uses ::operator new(size_t) and ::operator delete(void *p) directly (i.e., not a type specific operator new).

提交回复
热议问题