This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: bitset


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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]