std :: aligned_alloc()的重新分配等效项是什么? [英] What's the reallocation equivalent of std::aligned_alloc()?

查看:86
本文介绍了std :: aligned_alloc()的重新分配等效项是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 std :: aligned_alloc() 进入C ++ 17,我喜欢它.但是-当我需要重新分配时会发生什么?我可以手动执行此操作(假设当前分配的地址处的可用空间仅是我要求的空间量),但是标准库中是否应该没有此功能?

I've noticed std::aligned_alloc() coming into C++17, and I like it. But - what happens when I need to reallocate? I can do this manually (assuming the available space at the currently-allocated address is just the amount of space I asked for), but shouldn't there be a facility for this in the standard library?

推荐答案

没有等效的标准呼叫.

更是如此,微软最新的C ++实现仍然具有自己的 _aligned_malloc(),而不是现在标准化的 std :: aligned_alloc()此处他们解释了原因:

Even more so, Microsoft's latest implementation of C++ still has its own _aligned_malloc() instead of the now standardized std::aligned_alloc(), and here they explain why:

aligned_alloc()可能永远不会实现,如C11所指定它与我们的实施方式不兼容(即free()必须能够处理高度一致的分配.)

aligned_alloc() will probably never be implemented, as C11 specified it in a way that’s incompatible with our implementation (namely, that free() must be able to handle highly aligned allocations).

在他们的(微软的)带下划线前缀的实现中,它们确实为您提供 _aligned_realloc() :-)

Among their (Microsoft's) underscore-prefixed implementations they do serve you with _aligned_realloc() :-)

这篇关于std :: aligned_alloc()的重新分配等效项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆