public member function
<bitset>
std::bitset::testbool test (size_t pos) const;
Return bit value
Returns whether the bit at position pos is set (i.e., whether it is one).Unlike the access operator (operator[]), this function performs a range check on pos before retrieveing the bit value, throwing out_of_range if pos is equal or greater than the bitset size.
0
.
true
if the bit at position pos is set, and false
if it is not set.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// bitset::test
#include <iostream> // std::cout
#include <string> // std::string
#include <cstddef> // std::size_t
#include <bitset> // std::bitset
int main ()
{
std::bitset<5> foo (std::string("01011"));
std::cout << "foo contains:\n";
std::cout << std::boolalpha;
for (std::size_t i=0; i<foo.size(); ++i)
std::cout << foo.test(i) << '\n';
return 0;
}
foo contains: true true false true false
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4