bitset Multiple Values Assignment

M

Mike Copeland

Is there syntax that allows me to assign multiple bitset values at
runtime? Specifically, I have declared the following:

bitset<128> valGenders;

and I wish to assign default values during execution. I know that I can
do this:

bitset<128> numDights (string("-.0123456789"));

but because valGenders is defined in a structure that's allocated during
runtime I cannot use this syntax. I wish to assign all the bits for the
characters "MmFf" as a default set when I allocate a structure member,
but I can't find anything that shows how.
Or must I run through 4 individual valGenders.set() calls? 8<{{
Please advise. TIA
 
L

Luca Risolia

Is there syntax that allows me to assign multiple bitset values at
runtime? Specifically, I have declared the following:

bitset<128> valGenders;

and I wish to assign default values during execution. I know that I can
do this:

bitset<128> numDights (string("-.0123456789"));

You cannot do that. The constructor will throw a std::invalid_argument
exception, since the string contains characters different from "0" and "1".
but because valGenders is defined in a structure that's allocated during
runtime I cannot use this syntax. I wish to assign all the bits for the
characters "MmFf" as a default set when I allocate a structure member,
but I can't find anything that shows how.
Or must I run through 4 individual valGenders.set() calls? 8<{{
Please advise. TIA

Your problem is not very clear. Why cannot you just initialize the
bitset data member in the constructor initialization list of the struct?
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top