使用memcpy将vector 的内容复制到内存缓冲区中
std::vector<double> vec1 = {1.33,2.66,3.99};double* vec2 = new double;
int numMoments = 1;
::memcpy(
vec2,
vec1.data(),
numMoments * sizeof(double));
::memcpy(
vec2,
&(*vec1.begin()),
numMoments * sizeof(double));
::memcpy(
vec2,
&(vec1),
numMoments * sizeof(double));
页:
[1]