【发布时间】:2016-05-16 08:08:43
【问题描述】:
根据cppreference 和this answer,如果有用户声明的析构函数,C++ 应该不自动生成移动构造函数。但是,在使用 Clang 进行实践检查时,我看到了一个自动生成的移动构造函数。以下代码打印“is_move_constructible: 1”:
#include <iostream>
#include <type_traits>
struct TestClass
{
~TestClass()
{}
};
int main( int argc, char** argv )
{
std::cout << "is_move_constructible: " << std::is_move_constructible<TestClass>::value << std::endl;
}
我是否误解了“没有用户声明的析构函数”或 std::is_move_constructible?我正在使用 '-std=c++14' 和 Apple LLVM 版本 7.0.2 (clang-700.1.81) 进行编译。
【问题讨论】:
标签: c++ destructor c++14 move-constructor