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

Is bitset class is not a STL container?

P: n/a
>From the documentation of MSDN, it is saying that bitset is not a STL
container

Unlike the similar vector<boolClass, the bitset class does not have
iterators and is not an Standard Template Library container.

Actaully what's so special in STL containers?

What I know is that there will be certain operators overloaded,
supports template meta programming, having iterators, compatible with
other STL functions etc...

It would be helpful if you says what's missing in bitset container.

May 31 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 31 Maj, 02:09, Sarath <CSar...@gmail.comwrote:
From the documentation of MSDN, it is saying that bitset is not a STL

container

Unlike the similar vector<boolClass, the bitset class does not have
iterators and is not an Standard Template Library container.

Actaully what's so special in STL containers?

What I know is that there will be certain operators overloaded,
supports template meta programming, having iterators, compatible with
other STL functions etc...

It would be helpful if you says what's missing in bitset container.
First of all I think the term STL is a bit old, once there was
something called STL but that was later included in what is now know
as the C++ standard library. And bitset is part of the standard
library (I don't know if it was part of the original STL).

I think what you are asking about is what the difference between
bitset and the other containers in the standard library is, and I'd
answer that most of the normal container are generic and dynamic.
Meaning that they can contain elements of any type and are not fixed
in size.

The bitset on the other hand only contains bits (bools) and have a
fixed size. It's a very specialized container that can (which the
normal containers can't) perform some operations on all elements at
once (flip() is an example).

Since bitset is so specialized it does not make much sense to provide
some of the features that normal containers have (iterators is one
such feature) since in many cases there would be no use for the
features that would make sense.

--
Erik Wikström

May 31 '07 #2

P: n/a
Erik Wikström wrote:
>
First of all I think the term STL is a bit old, once there was
something called STL but that was later included in what is now know
as the C++ standard library.
Nevertheless, STL embodies the idea of algorithms and iterators,
supported by containers and callable types. Except when it refers to the
STandard Library (an unfortunate misuse of an otherwise useful term).
And bitset is part of the standard
library (I don't know if it was part of the original STL).
It wasn't.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
May 31 '07 #3

P: n/a
On Thu, 31 May 2007 07:12:00 -0400, Pete Becker wrote:
>Erik Wikström wrote:
>>
First of all I think the term STL is a bit old, once there was
something called STL but that was later included in what is now know
as the C++ standard library.

Nevertheless, STL embodies the idea of algorithms and iterators,
supported by containers and callable types. Except when it refers to the
STandard Library (an unfortunate misuse of an otherwise useful term).
However the original expansion of the acronym was "Standard Template
Library". Do you know why the adjective "standard" was used? That's
where, I guess, all the confusion is rooted.

--
Gennaro Prota -- C++ Developer, For Hire
https://sourceforge.net/projects/breeze/
(replace 'address' with 'name.surname' to mail)
May 31 '07 #4

P: n/a

Sarath <CS*****@gmail.comwrote in message ...
From the documentation of MSDN, it is saying that bitset is not a STL
container

Unlike the similar vector<boolClass, the bitset class does not have
iterators and is not an Standard Template Library container.
It's confusion!
My (old) STL docs list the 'bitset' as a 'container', but then say:

"
[two main differences between bitset and vector<bool>].
First, the size of a bitset cannot be changed: bitset's template parameter
N, which specifies the number of bits in the bitset, must be an integer
constant.

**
Second, bitset is not a Sequence; in fact, it is not an STL Container at
all.
**

It does not have iterators, for example, or begin() and end() member
functions. Instead, bitset's interface resembles that of unsigned integers.
It defines bitwise arithmetic operators such as &=, |=, and ^=.
"

So, it's an STL container which is NOT a container! <G>
Actaully what's so special in STL containers?
For one, they can increase and decrease in size ( see 'First' above).

Also, look up 'bit_vector' (and check if your implementation has it). The
1999 STL docs say it would be deprecated, but, it's still around today
(...well, at least in my GCC3.3(MinGW)). It IS a container (or was).

--
Bob R
POVrookie
May 31 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.