cpp/utility/bitset/operator at: Difference between revisions
From cppreference.com
adding header |
m {{p}} (for “paragraph”) gives lesser V offset. |
||
| (23 intermediate revisions by 10 users not shown) | |||
| Line 1: | Line 1: | ||
{{cpp/utility/bitset/title | operator[]}} | {{cpp/utility/bitset/title|operator[]}} | ||
{{cpp/utility/bitset/ | {{cpp/utility/bitset/}} | ||
{{ | {{begin}} | ||
{{ | {{|num=1| | ||
bool operator[]( size_t pos ) const; | bool operator[]( size_t pos ) const; | ||
}} | }} | ||
{{ | {{|num=2| | ||
reference operator[]( size_t pos ); | reference operator[]( size_t pos ); | ||
}} | }} | ||
{{ | {{end}} | ||
Accesses the bit at position {{ | Accesses the bit at position {{|pos}}. | ||
the value of the bit | |||
an object of type {{|reference}} that allows modification of the value. | |||
===Parameters=== | ===Parameters=== | ||
{{ | {{begin}} | ||
{{ | {{|pos|position of the bit to return}} | ||
{{ | {{end}} | ||
===Return value=== | ===Return value=== | ||
1 | 1the | ||
of the requested bit | |||
. | |||
===Example=== | ===Example=== | ||
{{example | {{example | ||
|code= | |||
#include <iostream> | #include <iostream> | ||
int main() | int main() | ||
{ | { | ||
std::bitset<8> b1 | std::bitset<8> b142 | ||
for ( | |||
for (i = 0; i < b1.size(); ++i) | |||
std::cout << "b1[" << i << "]: " << b1[i] << '\n'; | std::cout << "b1[" << i << "]: " << b1[i] << '\n'; | ||
0; | |||
} | } | ||
|output= | |||
b1[0]: 0 | b1[0]: 0 | ||
b1[1]: 1 | b1[1]: 1 | ||
| Line 45: | Line 56: | ||
b1[6]: 0 | b1[6]: 0 | ||
b1[7]: 0 | b1[7]: 0 | ||
}} | }} | ||
===See also=== | ===See also=== | ||
{{ | {{|}} | ||