Is bitset class is not a STL container?

S

Sarath

From the documentation of MSDN, it is saying that bitset is not a STL
container

Unlike the similar vector<bool> Class, 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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

container

Unlike the similar vector<bool> Class, 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.
 
P

Pete Becker

Erik said:
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)
 
G

Gennaro Prota

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.
 
B

BobR

Sarath said:
container

Unlike the similar vector<bool> Class, 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 said:
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).
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top