#include <type_traits> #include <memory> int main() { static_assert(std::is_copy_constructible<std::unique_ptr<int>>::value,"UPtr has copy constructor?"); }
但是没有.
使用MSVC12编译:
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
解决方法
(1) std::is_copy_constructible returns true for types with deleted
copy constructors.(2) std::is_copy_constructible returns true for types that compose
types that are not copy constructible.
答复是:
Thanks for reporting this bug. We’ve fixed it,and the fix will be available in the next major version of Visual Studio after 2013.
另请参阅此错误报告: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,"");
答复有:
Thanks for reporting this bug. We’ve already fixed it,and the fix is
available in VS 2015 Preview.
原文地址:https://www.jb51.cc/c/113445.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。