bitset..
Jan 13, 2012 at 4:07pm UTC
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]
Jan 13, 2012 at 4:22pm UTC
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 Jan 13, 2012 at 4:23pm UTC
Jan 13, 2012 at 4:30pm UTC
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.