This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: bitset
- From: "Rupert Wood" <me at rupey dot net>
- To: "'Rudra Banerjee'" <bnrj dot rudra at yahoo dot com>
- Cc: "'gcc'" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 10 Jul 2008 12:22:25 +0100
- Subject: RE: bitset
- References: <268314.57535.qm@web94107.mail.in2.yahoo.com>
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.