How to get element from circular_buffer

后端 未结 1 1658
轻奢々
轻奢々 2021-02-11 02:57

I am using boost library in MAC (xcode). I have two questions about boost::circular_buffer.

1 - I am getting syntax error when dec

相关标签:
1条回答
  • 2021-02-11 03:26

    boost::circular_buffer<T>::front() gives you a reference to the element at the "front", while boost::circular_buffer<T>::pop_front() will remove that element.

    boost::circular_buffer<T>::back() gives you a reference to the element at the back, while boost::circular_buffer<T>::pop_back() removes that element.

    It appears your syntax error is resulting from the most vexing parse. Try instead:

    boost::circular_buffer<int> cb;
    cb.set_capacity(10); 
    

    Or more succinctly:

    boost::circular_buffer<int> cb((10));
    
    0 讨论(0)
提交回复
热议问题