开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜