bitset..

Hello all,

I just so happened to stumble upon the 'bitset' class. Would it be worth it to store definitions of bitset values if there are many bools throughout a program?

1
2
#define boolfoo somebitset[0]
#define boolbar somebitset[1] 

Instead of #define you can use constants to access the bits in the bitset.
1
2
3
4
5
6
7
8
9
enum Item
{
	SWORD,
	AXE,
	ROPE,
	N_ITEMS
};
std::bitset<N_ITEMS> inventory;
inventory[AXE] = true;
Last edited on
true true, I was just thinking it would look more natural of it didn't look like an array.. meh.. cool :P
Topic archived. No new replies allowed.