Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Standard C++ Library Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

bitset

Module:  Standard C++ Library   Library:  Containers


Does not inherit

Local Index

Members

Summary

A class template and related functions for storing and manipulating fixed-size sequences of bits

Synopsis

#include <bitset>

namespace std {
  template <size_t N>
  class bitset;
}

Description

bitset is a class that describes objects that can store a sequence consisting of a fixed number of bits, N. Each bit represents either the value zero (reset) or one (set) and has a non-negative position pos.

Errors and Exceptions

Bitset constructors and member functions may throw the following exceptions:

If exceptions are not supported on your compiler, you get an assertion failure instead of an exception.

Interface

Constructors

bitset();
bitset(unsigned long val);
template<class charT, class traits, class Allocator>
explicit
bitset (const basic_string<charT, traits, Allocator>, 
        typename basic_string<charT, traits,
                              Allocator>::size_type=0, 
        typename basic_string<charT, traits,
                              Allocator>::size_type=
        basic_string<charT, traits, Allocator>::npos);
bitset(const bitset<N>& rhs);

Assignment Operators

bitset<N>& 
operator=(const bitset<N>& rhs);

Operators

bool 
operator==(const bitset<N>& rhs) const;
bool 
operator!=(const bitset<N>& rhs) const;
bitset<N>& 
operator&=(const bitset<N>& rhs);
bitset<N>& 
operator|=(const bitset<N>& rhs);
bitset<N>&
operator^=(const bitset<N>& rhs);
bitset<N>& 
operator<<=(size_t pos);
bitset<N>& 
operator>>=(size_t pos);
bitset<N>&
operator>>(size_t pos) const;
bitset<N>& 
operator<<(size_t pos) const;
bitset<N> 
operator~() const;
bitset<N> 
operator&(const bitset<N>& lhs,
          const bitset<N>& rhs);
bitset<N> 
operator|(const bitset<N>& lhs,
          const bitset<N>& rhs);
bitset<N> 
operator^(const bitset<N>& lhs,
          const bitset<N>& rhs);
template <size_t N>
basic_istream<charT, traits>m& 
operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
template <size_t N>
basic_ostream<charT, traits>& 
operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);

Member Functions

bool 
any() const;
size_t 
count() const;
bitset<N>& 
flip();
bitset<N>& 
flip(size_t pos);
bool 
none() const;
bitset<N>& 
reset();
bitset<N>& 
reset(size_t pos);
bitset<N>& 
set();
bitset<N>& 
set(size_t pos, bool val = true);
size_t 
size() const;
bool 
test(size_t pos) const;
unsigned long 
to_ulong() const;

Example

00000101

See Also

Containers

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 23.3.5



Previous fileTop of DocumentContentsIndex pageNext file

Copyright (c) 1994-2006 Rogue Wave Software, a Quovadx Division.
Licensed under the Apache License, Version 2.0.
Contact Rogue Wave about documentation or support issues. You can also seek help from other developers through the Apache stdcxx community (see below).

For more information on the Rogue Wave Standard C++ Library under open source, see Section 1.2 of the user's guide.