RE: bitset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rudra Banerjee wrote:

> bitset<bit> i (0);*(i.e. to read the bit as an integer variable)

No, what you're actually saying there is "define i as a bitset container for 'bit' bits". Since 'bit' can vary at runtime the compiler won't let you do this.

I don't know bitsets but looking at the docs to access bit x of a bitset container b you can use:

    b.test(x)

To test bit x of an integer i without using bitsets you can use:

    if ((i && (1 << x)) != 0)

or similar. Note that if i is something other than an integer you'll need a type suffix on the 1 in that expression, e.g. 1LL for long longs.

Hope that helps!
Rup.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux