bitset variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rudra

    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?
  • Ian Collins

    #2
    Re: bitset variable

    rudra wrote:
    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.

    Comment

    • Jerry Coffin

      #3
      Re: bitset variable

      In article <1efb223b-6b78-40f7-b4f7-8f7a34c1adb2
      @w7g2000hsa.goo glegroups.com>, bnrj.rudra@gmai l.com says...

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

      --
      Later,
      Jerry.

      The universe is a figment of its own imagination.

      Comment

      Working...