Why is there no reallocation functionality in C++ allocators?

前端 未结 5 1068
暖寄归人
暖寄归人 2020-11-29 06:56

In C the standard memory handling functions are malloc(), realloc() and free(). However, C++ stdlib allocators only parallel two of t

5条回答
  •  执笔经年
    2020-11-29 07:47

    Because of the object oriented nature of C++, and the inclusion of the various standard container types, I think it's simply that less focus was placed on direction memory management than in C. I agree that there are cases that a realloc() would be useful, but the pressure to remedy this is minimal, as almost all of the resulting functionality can be gained by using containers instead.

提交回复
热议问题