我正在使用GCC 5.2和clang 3.6进行测试,均在C++14模式下运行,它们都产生了相同的输出。
对于以下代码
#include <iostream>
#include <type_traits>
struct S {
// S& operator= (S&&) noexcept { return *this; }
};
int main() {
std::cout << std::is_nothrow_move_constructible<S>::value
<< std::is_nothrow_move_assignable<S>::value;
}
得到了结果11
。但是如果取消注释移动赋值运算符,输出结果就变成了01
。一个明确的noexcept
规范如何影响移动构造函数的规范呢?