Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 10th, 2008, 01:05 AM
rudra
Guest
 
Posts: n/a
Default bitset variable

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<32i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<biti (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?
  #2  
Old July 10th, 2008, 01:15 AM
Ian Collins
Guest
 
Posts: n/a
Default Re: bitset variable

rudra wrote:
Quote:
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<32i (0);
....etc.
where in bitset is equal to bit,which is 32. but i tried to write the
bitset as *bitset<biti (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.

--
Ian Collins.
  #3  
Old July 10th, 2008, 05:45 PM
Jerry Coffin
Guest
 
Posts: n/a
Default Re: bitset variable

In article <1efb223b-6b78-40f7-b4f7-8f7a34c1adb2
@w7g2000hsa.googlegroups.com>, bnrj.rudra@gmail.com says...

[ ... create a bitset where the size isn't a compile-time constant ]
Quote:
can you tell me a way to make that possible?
Boost Dynamic Bitset.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.