分配但不使用分配器的标准图书馆设施 [英] Standard library facilities which allocate but don't use an Allocator

查看:112
本文介绍了分配但不使用分配器的标准图书馆设施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在大多数C ++标准库分配内存的地方,用户可以通过提供满足

In most places where the C++ standard library allocates memory, the user is able to customise this by providing a class which meets the Allocator requirements. For example, almost all containers take an allocator template argument, and std::allocate_shared returns a shared_ptr whose contained element and control block are both allocated via a provided Allocator.

但是,在某些地方标准库可以(可能)分配内存,但是没有提供Allocator支持.我能想到的是:

However, there are a few places where the standard library can (potentially) allocate memory, but no Allocator support is provided. The ones I can think of are:

  • std::make_unique()(没有相应的allocate_unique())
  • std::any
  • std::function(分配器支持将在C ++ 17中删除)
  • std::valarray
  • std::basic_filebuf(尽管std::basic_stringbuf 确实使用分配器)
  • std::inplace_merge()
  • std::make_unique() (no corresponding allocate_unique())
  • std::any
  • std::function (allocator support will be removed in C++17)
  • std::valarray
  • std::basic_filebuf (although std::basic_stringbuf does use an Allocator)
  • std::inplace_merge()

问题:

  • 我确定此列表不完整,但是我还错过了什么?
  • 在非分配器的类和函数中,它们是否指定为使用全局::operator new,普通new,还是未指定内存源?
  • 如果有人知道,为什么不提供any中的分配器支持并将其从function中删除的原因是什么?
  • I'm sure this list is incomplete, but what else have I missed?
  • Of the non-Allocator classes and functions, are they specified to use global ::operator new, plain new, or is the memory source unspecified?
  • If anybody knows, what are the reasons for not providing allocator support in any, and removing it from function?

推荐答案

不是详尽的列表.

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