gpt4 book ai didi

C++ - 分配器类型提供的非平凡指针的构造是否会抛出异常?

转载 作者:行者123 更新时间:2023-11-28 01:58:44 25 4
gpt4 key购买 nike

这个问题不限于内置的 C++11 指针类型(shared_ptr 等),还包括可能在 C++ 中定义并作为符合标准的分配器的一部分包含的任何自定义指针类型。

非平凡指针的构造,例如由自定义分配器 (std::allocator_traits ::pointer) 提供的指针,是否会抛出异常,如果是,为什么?

最佳答案

[allocator.requirements]/4 An allocator type X shall satisfy the requirements of CopyConstructible (17.6.3.1). The X::pointer, X::const_pointer, X::void_pointer, and X::const_void_pointer types shall satisfy the requirements of NullablePointer (17.6.3.3). No constructor, comparison operator, copy operation, move operation, or swap operation on these types shall exit via an exception...

强调我的

关于C++ - 分配器类型提供的非平凡指针的构造是否会抛出异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40315492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com