Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++

Idiom #68 Create a bitset

Create an object x to store n bits (n being potentially large).

#include <vector>
std::vector<bool> x(n, 0);

This will create a vector of n bits initialized to 0.
#include <bitset>
std::bitset<n> x;
using System.Collections;
new BitArray(n);

New implementation...
< >
programming-idioms.org