我注意到标准库中有这样三种类型特征:
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_constructible
、is_nothrow_constructible
和 is_trivially_constructible
用于询问是否可以从一系列参数构造类型。显然,nothrow
和trivially
版本对选定的构造函数增加了额外的要求。它们是可变的; is_copy/move_constructible
不是。
所以这不是一回事。普通 constructible
版本或多或少是功能更集中的 copy/move
版本的超集。事实上,其他的(大部分)是根据可构造
形式定义的。
关于c++ - is_nothrow_xxxable 与 is_nothrow_move/copy_xxxable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37893553/