开发者

boost::circular_buffer increment begin pointer without use push_back()

开发者 https://www.devze.com 2023-04-01 21:21 出处:网络
I just want to increment pointer of boost::circular_buffer container without use of push_back() method. I s开发者_C百科aw an increment() method but it is in private section. I need write directly to c

I just want to increment pointer of boost::circular_buffer container without use of push_back() method. I s开发者_C百科aw an increment() method but it is in private section. I need write directly to circular buffer, because it is faster than I prepare the data and insert to buffer using push_back().

This is what I have now. It is slow because two copies are involved every time I push_back():

struct big_data_block
{
    char data[100000];
}; 

boost::circular_buffer<big_data_block> m_buffer(8);

void FillBuffer() 
{
    big_data_block block;
    ReadFromAnywhere(&block);
    buffer.push_back(block);
}

This is what I want, but function like IncrementBackPointer() does not exist.

void FillBuffer()
{
    ReadFromAnywhere(buffer.end() - 1);
    buffer.IncrementBackPointer();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消