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

前端 未结 5 1075
暖寄归人
暖寄归人 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:37

    I guess this is one of the things where god went wrong, but I was just too lazy to write to the standards committee.

    There should have been a realloc for array allocations:

    p = renew(p) [128];

    or something like that.

提交回复
热议问题