0

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?

Community
  • 1
  • 1
Kevvvvyp
  • 1,704
  • 2
  • 18
  • 38

1 Answers1

2

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.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Don't I need something like std::queue[14]> buttonQueue; as each message is an array of 14 bitsets each of size 8? – Kevvvvyp May 18 '15 at 13:37
  • @KevinPaton Handling of plain arrays can be problematic with templates, and passing around in general. Instead I suggest you use [`std::array`](http://en.cppreference.com/w/cpp/container/array), then you could do e.g. `std::queue, 14>>`, the queue would contain simple plain objects, that are in essence arrays of bitsets. – Some programmer dude May 18 '15 at 13:39