sji*_*sji 11 c++ type-traits c++11 msvc12
我原以为这个静态断言会被激发:
#include <type_traits>
#include <memory>
int main() {
static_assert(std::is_copy_constructible<std::unique_ptr<int>>::value, "UPtr has copy constructor?");
}
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.
使用MSVC12编译:
用于x64的Microsoft(R)C/C++优化编译器版本18.00.31101
Sha*_*our 15
本static_assert应该火,性病::的unique_ptr有一个隐含缺失的拷贝构造函数,所以这是一个错误.这看起来与此错误报告相关,std :: is_copy_constructible已损坏:
(1)对于具有已删除副本构造函数的类型,std :: is_copy_constructible返回true.
(2)对于组成不可复制构造类型的类型,std :: is_copy_constructible返回true.
而回应是:
感谢您报告此错误.我们已经修复了它,修复程序将在2013年后的Visual Studio的下一个主要版本中提供.
此外,请参阅此错误报告:std :: is_copy_constructible无法正常工作.
请注意,断言在使用最新版本的Visual Studio的webcompiler上触发.上次更新已开启Dec 3, 2015.断言也会对clang(看到它直播)和gcc发起攻击.
我发现了一个错误报告:std :: is_copy_constructible的一个奇怪的行为,它与你的代码非常相似:
static_assert(std::is_copy_constructible<std::unique_ptr<int>>::value, "");
Run Code Online (Sandbox Code Playgroud)
那里的回应是:
感谢您报告此错误.我们已经修复了它,修复程序在VS 2015 Preview中可用.
不清楚,修复了哪个版本的Visual Studio.一个响应说明2013年末版本,而后一个版本说2015预览版.