Is bitset class is not a STL container?

Discussion in 'C++' started by Sarath, May 31, 2007.

  1. Sarath

    Sarath Guest

    >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.
    Sarath, May 31, 2007
    #1
    1. Advertising

  2. On 31 Maj, 02:09, Sarath <> 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
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, May 31, 2007
    #2
    1. Advertising

  3. Sarath

    Pete Becker Guest

    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)
    Pete Becker, May 31, 2007
    #3
  4. 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)
    Gennaro Prota, May 31, 2007
    #4
  5. Sarath

    BobR Guest

    Sarath <> 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
    BobR, May 31, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maitre Bart
    Replies:
    2
    Views:
    519
    Maitre Bart
    Feb 11, 2004
  2. Replies:
    4
    Views:
    795
    Daniel T.
    Feb 16, 2006
  3. wolverine
    Replies:
    2
    Views:
    446
    Marcus Kwok
    Jul 24, 2006
  4. crea

    STL bitset class slow..

    crea, Mar 4, 2011, in forum: C++
    Replies:
    58
    Views:
    3,448
    Dilip
    Mar 20, 2011
  5. Ninds
    Replies:
    14
    Views:
    725
    W Karas
    Dec 3, 2012
Loading...

Share This Page