std::bitset::bitset
Aus cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> constexpr bitset() noexcept; |
(1) | |
constexpr bitset( unsigned long long val ) noexcept; |
(2) | |
template< class CharT, class Traits, class Allocator > explicit bitset( const std::basic_string<CharT,Traits,Allocator>& str, typename std::basic_string<CharT,Traits,Allocator>::size_type pos = 0, typename std::basic_string<CharT,Traits,Allocator>::size_type n = std::basic_string<CharT,Traits,Allocator>::npos); bitset( const std::basic_string<CharT,Traits,Allocator>& str, typename std::basic_string<CharT,Traits,Allocator>::size_type pos = 0, typename std::basic_string<CharT,Traits,Allocator>::size_type n = std::basic_string<CharT,Traits,Allocator>::npos, CharT zero = CharT(’0’), CharT one = CharT(’1’)); |
(3) | (bis C + +11) (seit C++11) |
template< class CharT > explicit bitset( const CharT* str, typename std::basic_string<CharT>::size_type n = std::basic_string<CharT>::npos, CharT zero = CharT(’0’), CharT one = CharT(’1’)); |
(4) | (seit C++11) |
Erzeugt ein neues bitset aus einer von mehreren optional Datenquellen:
Original:
Constructs a new bitset from one of several optional data sources:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ein. Standardkonstruktor. Erzeugt ein bitset bei der alle Bits auf Null gesetzt .
Original:
1. Default constructor. Constructs a bitset with all bits set to zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2. Erzeugt ein bitset mit den Bits in
val. Wenn die N ist die Größe des bitset und M ist die Anzahl der gesetzten Bits in val, dann nur min (N, M) Bits werden in der bitset aufgenommen werden .Original:
2. Constructs a bitset using the bits in
val. If the N is the size of the bitset and M is the number of set bits in val, then only min(N, M) bits will be included in the bitset.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3. Erzeugt ein bitset mit den Zeichen im std::basic_string
str. Eine optionale Startposition und Länge pos n vorgesehen sein sowie Zeichen bezeichnet alternative Werte für Satz (one) und ungeschränkten (zero) Bits . Original:
3. Constructs a bitset using the characters in the std::basic_string
str. An optional starting position pos and length n can be provided, as well as characters denoting alternate values for set (one) and unset (zero) bits. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Die wirksame Länge der Saite ist Initialisieren min (
n, str.size() - pos) .Original:
The effective length of the initializing string is min(
n, str.size() - pos).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Wenn
pos > str.size(), wirft dieser Konstruktor std::out_of_range. Wenn alle Zeichen untersucht str nicht zero oder one, wirft es std::invalid_argument .Original:
If
pos > str.size(), this constructor throws std::out_of_range. If any characters examined in str are not zero or one, it throws std::invalid_argument.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4. Ähnlich wie bei (3), verwendet jedoch ein
CharT* anstelle eines std::basic_string .Original:
4. Similar to (3), but uses a
CharT* instead of a std::basic_string.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| val | - | Nummer für den bitset initialisieren
Original: number used to initialize the bitset The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| str | - | Zeichenfolge verwendet, um die bitset initialisieren
Original: string used to initialize the bitset The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| pos | - | Ein Ausgangspunkt in
str ausgeglichenOriginal: a starting offset into strThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| n | - | Anzahl der Zeichen von
str verwendenOriginal: number of characters to use from strThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| one | - | alternativen Zeichensatz für Bits in
strOriginal: alternate character for set bits in strThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| zero | - | alternative Zeichen für unset Bits in
strOriginal: alternate character for unset bits in strThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Ausnahmen
Ein. keine
Original:
1. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2. keine
Original:
2. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3. std::out_of_range if pos > str.size()
4. keine
Original:
4. none
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Beispiel
#include <bitset>
#include <string>
int main()
{
// empty constructor
std::bitset<8> b1; // [0,0,0,0,0,0,0,0]
// unsigned long long constructor
std::bitset<8> b2(42); // [0,0,1,0,1,0,1,0]
// string constructor
std::string bit_string = "110010";
std::bitset<8> b3(bit_string); // [0,0,1,1,0,0,1,0]
std::bitset<8> b4(bit_string, 2); // [0,0,0,0,0,0,1,0]
std::bitset<8> b5(bit_string, 2, 3); // [0,0,0,0,0,0,0,1]
// string constructor using custom zero/one digits
std::string alpha_bit_string = "aBaaBBaB";
std::bitset<8> b6(alpha_bit_string, 0, alpha_bit_string.size(),
'a', 'B'); // [0,1,0,0,1,1,0,1]
// char* constructor using custom digits
std::bitset<8> b7("XXXXYYYY", 0, 'X', 'Y'); // [0,0,0,0,1,1,1,1]
return 0;
}
Siehe auch
sets bits to true or given value (öffentliche Elementfunktion) | |
setzt Bits falseOriginal: sets bits to falseThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (öffentliche Elementfunktion) | |