Search code examples
c++queuebitset

How to create a Bitset Array Queue?


I am reading in 14 byte messages from a device and I store them in an array of bitsets...

bitset<8> currentMessage[14];

I want to create a queue of these messages. (Ideally I want the last 10 messages but I think that might be a whole other question? limit size of Queue<T> in C++.)

How can I create this queue?

I tried...

std::queue<bitset> buttonQueue;

but I received the following errors:

  • error C2955: 'std::bitset' : use of class template requires template argument list
  • error C2133: 'buttonQueue' : unknown size
  • error C2512: 'std::queue' : no appropriate default constructor available

(N.B. I noticed Boost's Circular Buffer, could this be a more suited alternative for what I'm trying to do?)

I'm pretty new to c++, can anyone help me out?


Solution

  • The template argument need to be a full and complete type. And a templated class like std::bitset is not a complete type without its size. So you need to do e.g.

    std::queue<bitset<8>> buttonQueue;
    

    In other words, you need to provide the bitset size as well.