我std::vector
用来在我的Image类中存储图像。我很难理解它们是如何工作的。旋转图像的函数:
void Image :: resize (int width, int height)
{
//the image in the object is "image"
std::vector<uint8_t> vec; //new vector to store rotated image
// rotate "image" and store in "vec"
image = vec; // copy "vec" to "image" (right?)
//vec destructs itself on going out of scope
}
有什么办法可以防止最后一个副本?就像在 Java 中一样,只是通过切换引用?如果防止任何复制,那就太好了。