Search code examples
c++cbitmapunsigned-integer

a bit map in c++ - will unsigned int do the job?


I'm afraid to admit, I haven't used C++ for a while now but i'm afraid I have to now, and I'm a bit rusty.
I need to have a bitmap, and I do care about performance, my bitmap size will be no longer then 25 bits.
I was thinking about using unsigned int, but I am afraid I do not remember how it is implemented in c/c++

Is unsigned int implemented as a regular binary number?
I am also open to any other suggestions for a bitmap.
thanks in advance for the help!


Solution

  • Use an std::bitset<25> from the header <bitset>. bitset can be indexed with [] and is a template, so it likely expands to just an unsigned int (or equivalent) with all operations inlined.