HP/SGI
Prev | Chapter 34. Containers | Next

## HP/SGI

A few extensions and nods to backwards-compatibility have been made with containers. Those dealing with older SGI-style allocators are dealt with elsewhere. The remaining ones all deal with bits:

The old pre-standard `bit_vector` class is present for backwards compatibility. It is simply a typedef for the `vector<bool>` specialization.

The `bitset` class has a number of extensions, described in the rest of this item. First, we'll mention that this implementation of `bitset<N>` is specialized for cases where N number of bits will fit into a single word of storage. If your choice of N is within that range (<=32 on i686-pc-linux-gnu, for example), then all of the operations will be faster.

There are versions of single-bit test, set, reset, and flip member functions which do no range-checking. If we call them member functions of an instantiation of "bitset<N>," then their names and signatures are:

       bitset<N>&   _Unchecked_set   (size_t pos);
       bitset<N>&   _Unchecked_set   (size_t pos, int val);
       bitset<N>&   _Unchecked_reset (size_t pos);
       bitset<N>&   _Unchecked_flip  (size_t pos);
       bool         _Unchecked_test  (size_t pos);

Note that these may in fact be removed in the future, although we have no present plans to do so (and there doesn't seem to be any immediate reason to).

The semantics of member function `operator[]` are not specified in the C++ standard. A long-standing defect report calls for sensible obvious semantics, which are already implemented here: `op[]` on a const bitset returns a bool, and for a non-const bitset returns a `reference` (a nested type). However, this implementation does no range-checking on the index argument, which is in keeping with other containers' `op[]` requirements. The defect report's proposed resolution calls for range-checking to be done. We'll just wait and see...

Finally, two additional searching functions have been added. They return the index of the first "on" bit, and the index of the first "on" bit that is after `prev`, respectively:

       size_t _Find_first() const;
       size_t _Find_next (size_t prev) const;

The same caveat given for the _Unchecked_* functions applies here also.

Prev | Up | Next
Chapter 34. Containers | Home | Deprecated HP/SGI