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

A dynamic bitset?

P: n/a
How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!

Nov 4 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
to**********@students.fh-vorarlberg.ac.at wrote:
How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!


boost::dynamic_bitset
Nov 4 '05 #2

P: n/a
to**********@students.fh-vorarlberg.ac.at wrote:
How would be the best solution to create a dynamic bitset cause with
the stl bitset you have to give a number of how big the bitset will be
and i dont know the size at the beginning...

Thanks very much!!


vector<bool> is a possibility. Depends exactly what you want to do.

john
Nov 4 '05 #3

P: n/a
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility

Nov 4 '05 #4

P: n/a
to**********@vol.at wrote:
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility


'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #5

P: n/a

Andrey Tarasevich schrieb:
to**********@vol.at wrote:
vector<bool> would be too big for me... But vector<bitset<32> > is a
possibility


'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.

--
Best regards,
Andrey Tarasevich


Really?!? But when i had to write convertations from numbers to bits
and from bits to numbers.... Correct?

Nov 4 '05 #6

P: n/a
to**********@vol.at wrote:
> vector<bool> would be too big for me... But vector<bitset<32> > is a
> possibility
'std::vector<bool>' is supposed to be specialized as a bit-vector, not as a
plain vector of 'bool' objects, meaning that it will be essentially the same as
your 'vector<bitset<32> >', but with more natural interface. Check your
standard library implementation.


Really?!?


Yes.
But when i had to write convertations from numbers to bits
and from bits to numbers.... Correct?


Er... Sorry, but I don't understand the question. Can you please clarify?

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #7

P: n/a
With bitsets you can make things like:

bitset<32> bits(12);
bits = 4;
int var = bits.to_ulong();

So i can create the bits out of a number. With this bitvectors i had to
write such functions...

Nov 4 '05 #8

P: n/a
to**********@vol.at wrote:
With bitsets you can make things like:

bitset<32> bits(12);
bits = 4;
int var = bits.to_ulong();

So i can create the bits out of a number. With this bitvectors i had to
write such functions...


Yes, with 'std::vector<bool>' you'll have to write it yourself or use a
third-party implementation.

--
Best regards,
Andrey Tarasevich
Nov 4 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.