std::bitset::to_string
Da 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. |
template< class CharT, | (até C++11) (desde C++11) | |
Converte o conteúdo do bitset a uma corda.
zero
usa para representar bits com valor de false e one
para representar bits com valor de true.Original:
Converts the contents of the bitset to a string. Uses
zero
to represent bits with value of false and one
to represent bits with value of true.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.
A seqüência de caracteres resultante contém
N
com o primeiro caractere corresponde ao bit (N-1
th) passado e do último caractere correspondente ao primeiro bit.Original:
The resulting string contains
N
characters with the first character corresponds to the last (N-1
th) bit and the last character corresponding to the first bit.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.
Índice |
[editar]Parâmetros
zero | - | caractere usado para representar false Original: character to use to represent false The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
one | - | caractere usado para representar true Original: character to use to represent true The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar]Valor de retorno
a seqüência convertida
Original:
the converted 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.
[editar]Exemplo
#include <iostream>#include <bitset>int main(){std::bitset<8> b(42);std::cout<< b.to_string()<<'\n'<< b.to_string('*')<<'\n'<< b.to_string('O', 'X')<<'\n';}
Saída:
00101010 **1*1*1* OOXOXOXO
[editar]Veja também
retorna uma representação de número inteiro unsignedlong dos dados Original: returns an unsignedlong integer representation of the data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) | |
(C++11) | retorna uma representação de número inteiro unsignedlonglong dos dados Original: returns an unsignedlonglong integer representation of the data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (função pública membro) |