Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Is bitset class is not a STL container?

Reply
Thread Tools

Is bitset class is not a STL container?

 
 
Sarath
Guest
Posts: n/a
 
      05-31-2007
>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.

 
Reply With Quote
 
 
 
 
=?iso-8859-1?q?Erik_Wikstr=F6m?=
Guest
Posts: n/a
 
      05-31-2007
On 31 Maj, 02:09, Sarath <(E-Mail Removed)> wrote:
> >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.


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

 
Reply With Quote
 
 
 
 
Pete Becker
Guest
Posts: n/a
 
      05-31-2007
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)
 
Reply With Quote
 
Gennaro Prota
Guest
Posts: n/a
 
      05-31-2007
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)
 
Reply With Quote
 
BobR
Guest
Posts: n/a
 
      05-31-2007

Sarath <(E-Mail Removed)> wrote in message ...
> >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.
>


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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bitset<32> and bitset<64> efficiency Ninds C++ 14 12-03-2012 11:02 PM
STL bitset class slow.. crea C++ 58 03-20-2011 09:32 PM
some questions about "bitset" class arnuld C++ 2 07-20-2007 08:06 AM
BitSet Class Implementation Erick Crouse Java 4 11-20-2006 06:45 PM
Inheriting from STL bitset shaun roe C++ 29 11-08-2004 06:03 PM



Advertisments