Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6331079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:59:22+00:00 2026-05-24T17:59:22+00:00

I like Boost Templated Circular Buffer Container , but how to get when it

  • 0

I like Boost Templated Circular Buffer Container, but how to get when it was filled 100%?

   #include <boost/circular_buffer.hpp>

   int main() {

      // Create a circular buffer with a capacity for 3 integers.
      boost::circular_buffer<int> cb(3);

      // Insert some elements into the buffer.
      cb.push_back(1);
      cb.push_back(2);
      cb.push_back(3);

      // Here I want some function to be called (for example one that would cout all buffer contents)

      int a = cb[0];  // a == 1
      int b = cb[1];  // b == 2
      int c = cb[2];  // c == 3

      return 0;
   }

So how to listen for such event in boost::circular_buffer and for example cout all buffer contents?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:59:24+00:00Added an answer on May 24, 2026 at 5:59 pm

    You can wrap the circular_buffer instance into its own class and implement event handling on top of it.

    class MyCircularBuffer
    {
    public:
        MyCircularBuffer() : buffer(3) {}
    
        void PushBack(int i)
        {
            buffer.push_back(i);
            if(buffer.size() == 3)
            {
                // buffer is full!
            }
        }
    private:
        boost::circular_buffer<int> buffer;
    };
    

    If code outside of MyCircularBuffer needs to be notified of the event, you can implement some variant of the Observer pattern, use Boost.Function or use some other callback mechanism.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple C++ with Boost like this: #include <boost/algorithm/string.hpp> int main() {
The following program: #include <boost/range/concepts.hpp> #include <iterator> #include <istream> using boost::range_detail::SinglePassIteratorConcept; int main() {
I have a object cache class like this: #include boost/thread/mutex.hpp #include boost/unordered_map.hpp template <typename
So I have such log class: #include <iostream> #include <sstream> #include <boost/circular_buffer.hpp> #include <boost/foreach.hpp>
in my code i would like boost::shared_ptr not to call delete but call ptr->deleteMe()
I am programming with normal pointers, but I have heard about libraries like Boost
The topic generically says it all. Basically in a situation like this: boost::scoped_array<int> p(new
I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor
I am implementing a templated sparse_vector class. It's like a vector, but it only
I'm currently porting atomic.hpp out of boost for a project and would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.