std::bitset::operator[]

Da cppreference.com.
< cpp‎ | utility‎ | bitset

 
 
Utilità libreria
Tipo di supporto (basic types, RTTI, type traits)
Gestione della memoria dinamica
La gestione degli errori
Programma di utilità
Funzioni variadic
Data e ora
Funzione oggetti
initializer_list(C++11)
bitset
hash(C++11)
Gli operatori relazionali
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Coppie e tuple
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
Swap, in avanti e spostare
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
std::bitset
Membri tipi
Original:
Member types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::reference
Membri funzioni
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::bitset
bitset::operator==
bitset::operator!=
Elemento accesso
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator[]
bitset::test
bitset::all
bitset::any
bitset::none
(C++11)

 
bitset::count
Capacità
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::size
Modificatori
Original:
Modifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::operator&=
bitset::operator|=
bitset::operator^=
bitset::operator~
bitset::operator<<=
bitset::operator>>=
bitset::operator<<
bitset::operator>>
bitset::set
bitset::reset
bitset::flip
Conversioni
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bitset::to_string
bitset::to_ulong
bitset::to_ullong(C++11)
Non membri funzioni
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator&
operator|
operator^
operator<<
operator>>
Helper classi
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::hash(C++11)
 
bool operator[](std::size_t pos )const;
constexprbool operator[](std::size_t pos )const;
(1) (fino al c++11)
(dal C++11)
reference operator[](std::size_t pos );
(2)
Accede al bit in pos posizione. La prima versione restituisce il valore del bit, la seconda versione restituisce un oggetto di std::bitset::reference tipo che consente la modifica del valore.
Original:
Accesses the bit at position pos. The first version returns the value of the bit, the second version returns an object of type std::bitset::reference that allows modification of the value.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
A differenza di test(), non genera eccezioni: il comportamento è indefinito se pos è fuori dai limiti.
Original:
Unlike test(), does not throw exceptions: the behavior is undefined if pos is out of bounds.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Indice

[modifica]Parametri

pos -
posizione del bit di ritornare
Original:
position of the bit to return
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Valore di ritorno

1)
il valore del bit richiesto
Original:
the value of the requested bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
un oggetto di tipo std::bitset::reference, che permette la scrittura del bit richiesto.
Original:
an object of type std::bitset::reference, which allows writing to the requested bit.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Eccezioni

Nessuno
Original:
None
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[modifica]Esempio

#include <iostream>#include <bitset>   int main(){std::bitset<8> b1(42);for(std::size_t i =0; i < b1.size();++i){std::cout<<"b1["<< i <<"]: "<< b1[i]<<'\n';} b1[0]=true;// modifies the first bit through bitset::refencestd::cout<<"After setting bit 0, the bitset holds "<< b1 <<'\n';}

Output:

b1[0]: 0 b1[1]: 1 b1[2]: 0 b1[3]: 1 b1[4]: 0 b1[5]: 1 b1[6]: 0 b1[7]: 0 After setting bit 0, bitset is 00101011

[modifica]Vedi anche

accede specifico bit
Original:
accesses specific bit
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(metodo pubblico)[modifica]
close