Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
bitset
bitset::bitset
bitset operators
member functions:
bitset::any
bitset::count
bitset::flip
bitset::none
bitset::operator[]
bitset::reset
bitset::set
bitset::size
bitset::test
bitset::to_string
bitset::to_ulong


bitset::size

public member function
size_t size() const;

Return size

Returns the number of bits in the bitset.

Parameters

none

Return Value

The number of bits in the bitset. This is the template parameter N.

size_t is an unsigned integral type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// bitset::size
#include <iostream>
#include <bitset>
using namespace std;
int main ()
{
  bitset<8> first;
  bitset<4> second;
  cout << "first.size() is " << (int) first.size() << endl;
  cout << "second.size() is " << (int) second.size() << endl;
  return 0;
}


Output:
first.size() is 8
second.size() is 4

See also