简体   繁体   中英

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:

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();

the right command is:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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