bitset variable

R

rudra

Dear friends,
i am in mess with bitset again. i have managed to write a messy code
which checks the machine bitsize and then wants to do a bitflip. here
is the code:
int bit;
if (strncmp(sysptr, "i686",4)==0)
{
bit=32;
}
......
bitset<32> i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<bit> i (0);*(i.e. to read the bit)
where its giving the error:error: ‘bit’ cannot appear in a constant-
expression
can you tell me a way to make that possible?
 
I

Ian Collins

rudra said:
Dear friends,
i am in mess with bitset again. i have managed to write a messy code
which checks the machine bitsize and then wants to do a bitflip. here
is the code:
int bit;
if (strncmp(sysptr, "i686",4)==0)
{
bit=32;
}
......
bitset<32> i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<bit> i (0);*(i.e. to read the bit)
where its giving the error:error: ‘bit’ cannot appear in a constant-
expression
can you tell me a way to make that possible?

You can't. Template (integer) arguments must be compile time constants.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top