Chapter     18

STL’s bitset

The last STL container type object that I cover is the bitset. I say STL type because the bitset is not strictly a container. It does not support iterators, the range-based for loops, or STL’s algorithms. A bitset is used for tracking individual boolean values in a combined set. A traditional method for achieving the same result are flags implemented using bitwise operators and shifts.

Creating bitset Objects

A bitset is yet another template provided by the STL. A major difference between a bitset and other STL containers is that you are not required to specify a type for the bitset. You can see in Listing 18-1 that the only parameter taken by the template is the number of bit flags we would like the bitset to contain. ...

Get Learn C++ for Game Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.