[英]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.