c++ - is_nothrow_xxxable 与 is_nothrow_move/copy_xxxable

标签 c++ c++11

我注意到标准库中有这样三种类型特征:

std::is_nothrow_constructible       // (1)
std::is_nothrow_copy_constructible  // (2)
std::is_nothrow_move_constructible  // (3)

(2)(3)的意思从名字就可以看出来,但是(1)到底是什么意思呢?它是 (2)(3) 的逻辑与、(2)(3) 的逻辑或,还是其他?

同样,我们可以将nothrow替换为trivially,将constructible替换为assignable

最佳答案

is_constructibleis_nothrow_constructibleis_trivially_constructible 用于询问是否可以从一系列参数构造类型。显然,nothrowtrivially 版本对选定的构造函数增加了额外的要求。它们是可变的; is_copy/move_constructible 不是。

所以这不是一回事。普通 constructible 版本或多或少是功能更集中的 copy/move 版本的超集。事实上,其他的(大部分)是根据可构造形式定义的。

关于c++ - is_nothrow_xxxable 与 is_nothrow_move/copy_xxxable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37893553/

相关文章:

c++ - 指向尚未初始化的成员

c++ - 如何在 C++ 中为二维 vector 做构造函数?

c++ - 在 Qt 中缩放图形

c++ - 在编译时生成唯一编号

c++ - 在 move 构造函数中窃取

c++ - 在 C++11 中将 fstream 引用作为函数参数传递

C++ const 数组追加

c++ - 我在下面关于 C++ 标准中的 §9.3.1/3 的观察是否正确?

c++ - 使用 boost 和 asio 运行线程

c++ - 在构造函数中使用 std::vector 损坏内存