本文介绍了std :: vector :: resize(size_type)要求CopyInsertable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这个问题是在我回答时提出的这个另一个问题。 N3337 23.3.6.3矢量能力说(在770页):但是, resize(size_type)只需要可销毁/可移动/默认可构造。它会破坏 sz ,追加(使用默认构造,如果容量不足则销毁和移动)if size < sz 。 什么是真理?这是标准缺陷吗?或者是clang ++和我的错误吗?解决方案你是正确的。这是C ++ 11中的一个缺陷,通过 http ://cplusplus.github.io/LWG/lwg-defects.html#2033 目前的措辞为:However, clang++ says it's okay though T is not copyable. And I think it makes sense that resize(size_type) requires only destroyable/moveable/default constructable. It destroys if sz <= size, appends (which uses default constructing, and destroying and moving if the capacity is not enough) if size() < sz.What is truth? Is it a standard defect? Or is it a mistake of both clang++ and me? 解决方案 You are correct. It was a defect in C++11 that was fixed for C++14 by http://cplusplus.github.io/LWG/lwg-defects.html#2033The current wording says:The requirement on Destructible is in Table 95 and applies to all operations on all containers, not just resize(). 这篇关于std :: vector :: resize(size_type)要求CopyInsertable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!