std::allocator_arg
定义于 | 内存 |
自 C++17 起
inline constexpr std::allocator_arg_t allocator_arg = std::allocator_arg_t();
自 C++11 起
struct allocator_arg_t { explicit allocator_arg_t() = default; };
constexpr std::allocator_arg_t allocator_arg = std::allocator_arg_t(); // Until C++17
std::allocator_arg_t 是一个空类类型,用于消除构造函数和感知分配器的对象的成员函数(包括std::tuple、std::function、std::packaged_task 和 (C++17 之前)以及 std::promise)的重载歧义。std::allocator_arg 是它的一个常量。
缺陷报告
以下改变行为的缺陷报告已追溯应用于先前发布的 C++ 标准。
DR | 应用于 | 发布时的行为 | 正确行为 |
---|---|---|---|
LWG 2510 | C++11 | 默认构造函数不是 explicit 的,这可能导致歧义 | 已声明为 explicit |