[英]Error with assigning memory to std::array
我的意图是将队列中的图像缓冲区传递给其他一些 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>()’
和
error: no matching function for call to ‘std::deque<std::array<unsigned char, 345600> >::push_back(std::array<unsigned char, 345600> (&)())’
这是我的代码,我想知道错误在哪里
// 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);
谢谢
我认为你不应该在这一行的框架前使用括号:
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.