如果我创建
std::vector<std::array<double, 2>> points;
std::vector<double> points2;
我知道points2是一个在堆上持有double的连续内存块。我认为points是一个指向堆栈上double*的连续内存块?但是,这些数组在堆栈中是连续的吗?假设我正在存储双精度浮点数对来表示某些点。 points2在内存中是这样的:[x0 y0 x1 y1 x2 y2 ...] 那么points呢?在这种情况下,最好的方法是如何存储双精度浮点数对?感谢任何提示。
struct Point { double x; double y; }
å’Œvector<Point> points;
。 - Eljaystd::array
是一个围绕 C 风格数组的轻量级封装,因此它存储实际的数组而不是数组指针。 - UnholySheep