c – 为什么在MSVC12中,is_copy_constructible为unique_ptr返回t
我会预料这个静态断言:
#include <type_traits> #include <memory> int main() { static_assert(std::is_copy_constructible<std::unique_ptr<int>>::value,"UPtr has copy constructor?"); } 但是没有. 使用MSVC12编译:
解决方法
static_assert应该触发,std::unique_ptr有一个隐式删除的副本构造函数,所以这是一个错误.这看起来与这个bug报告
std::is_copy_constructible is broken有关:
答复是:
另请参阅此错误报告:std::is_copy_constructible doesn’t work correctly. 请注意,使用最新版本的Visual Studio的webcompiler上的断言触发.最后一次更新是在2015年12月3日.断言也在cl(see it live)和gcc上触发. 我发现一个错误报告:A strange behavior of std::is_copy_constructible它与你的代码非常相似: static_assert(std::is_copy_constructible<std::unique_ptr<int>>::value,""); 答复有:
不清楚,这是什么版本的Visual Studio这是固定的.一个回应说,2013年底版本,而后期说2015年预览. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |