简体   繁体   English

将 memory 分配给 std::array 时出错

[英]Error with assigning memory to std::array

My intention is to pass a image buffer in a queue to some other function (in another thread) for processing, using example in http://www.cplusplus.com/reference/array/array/data/ .However I have gotten the following error:我的意图是将队列中的图像缓冲区传递给其他一些 function(在另一个线程中)进行处理,使用http://www.cplusplus.com/reference/array/array/data/中的示例。以下错误:

error: request for member ‘data’ in ‘frame’, which is of non-class type ‘std::array<unsigned char, 345600>()’

and

error: no matching function for call to ‘std::deque<std::array<unsigned char, 345600> >::push_back(std::array<unsigned char, 345600> (&)())’

This is my code and I wonder where is the error这是我的代码,我想知道错误在哪里

// Declaration of array  
std::deque<std::array<unsigned char, FRAME_WIDTH * FRAME_HEIGHT>> frameQueue;

// some processing
// some processing take place and the output is some buffer buf , type unsigned char 

// declare an array object
std::array<unsigned char, FRAME_HEIGHT * FRAME_WIDTH> frame();

// set the array with memory from buf
std::memcpy (frame.data(), buf, FRAME_HEIGHT * FRAME_WIDTH);

// push it into queue
frameQueue.push_back(frame);

THanks谢谢

I think you should not using parentheses in front of the frame in this line:我认为你不应该在这一行的框架前使用括号:

std::array<unsigned char, FRAME_HEIGHT * FRAME_WIDTH> frame(); std::array<unsigned char, FRAME_HEIGHT * FRAME_WIDTH> frame();

the right command is:正确的命令是:

std::array<unsigned char, FRAME_HEIGHT * FRAME_WIDTH> frame; std::array<unsigned char, FRAME_HEIGHT * FRAME_WIDTH> 帧;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM