By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,382 Members | 1,688 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,382 IT Pros & Developers. It's quick & easy.

candidate for bitset

P: n/a

Given an unsigned int variable that's part of a composite type
struct test {
unsigned int mask;
};

Assume 4 bytes for unsigned int. In one function, I'd like to set
any bit or combination of bits between bits 0 and 23 for the parameter
mask.

So lets suppose I set bits 5, 15 and 23 of mask.

In a separate function I'd like to decode that and store the location
of the bit that was set in a vector .. so in the vector I'd have 5, 15
and 23.

Is this a candidate for bitset? Cant seem to get that to work for me,
then again I'm probably on the wrong track. Trying to determine a way
to make this seemless.

Thanks in advance...

Dec 14 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ma740988 wrote:
Given an unsigned int variable that's part of a composite type
struct test {
unsigned int mask;
};

Assume 4 bytes for unsigned int. In one function, I'd like to set
any bit or combination of bits between bits 0 and 23 for the parameter
mask.

So lets suppose I set bits 5, 15 and 23 of mask.

In a separate function I'd like to decode that and store the location
of the bit that was set in a vector .. so in the vector I'd have 5, 15
and 23.

Is this a candidate for bitset? Cant seem to get that to work for me,
then again I'm probably on the wrong track. Trying to determine a way
to make this seemless.


Just have fun and implement your own "bitset". What do you think you
can use from std::bitset? 'set' and 'reset'? And std::bitset has no
enumeration, really. So, you'd have to loop over the collection anyway.
Why not challenge your brain to a bit of coding once in a while? :-)

V
Dec 14 '05 #2

P: n/a
Happy holidays Vic.
|| Why not challenge your brain to a bit of
|| coding once in a while? :-)
Ok

Dec 14 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.