Chapter 22. HP/SGI Extensions

Table of Contents

Backwards Compatibility
Deprecated

Backwards Compatibility

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 member function operator[] on a const bitset returns a bool, and for a non-const bitset returns a reference (a nested type). No range-checking is done on the index argument, in keeping with other containers' operator[] requirements.

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.