Boost logo

Boost :

Subject: [boost] [assign] operators+= and -= for set/reset bits in std::bitset
From: Winkler, Bernd (Bernd.Winkler_at_[hidden])
Date: 2010-12-07 04:11:15


Dear All,
 
I was a little bit tired of using string initialization of std::bitset
like:
 
bitset<8> flag_pattern(string("00111000"));
 
What I found more readable was this:
 
Bitset<8> flag_pattern; //initialisation to "00000000"
flag_pattern += 1,3,4,5; //set bits at indices 1,3,4,5 to true: 01011100
flag_pattern -= 1,3; //set bits at indices 1,3 to false: 00001100
 
In that way I can specify an easy readable configuration of flags:
 
enum
{
   left,
   right,
   center
}
 
flag_pattern += left,right;
 
If interest exists I could contribute the respective code for the assign
library.
 
Best regards,
Bernd
 
P.S. Please let me know if I missed some formal criteria for this post
as I am new to this NG


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk