std::bitset::to_string
De 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> template< class CharT, class Traits, class Allocator > std::basic_string<CharT,Traits,Allocator> to_string() const; template< class CharT = char, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT> > std::basic_string<CharT,Traits,Allocator> to_string(CharT zero = CharT(’0’), CharT one = CharT(’1’)) const; |
(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-1th) 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-1th) 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.
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. |
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.
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
Veja também
retorna uma representação de número inteiro unsigned long dos dadosOriginal: returns an unsigned long integer representation of the dataThe 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 unsigned long long dos dados Original: returns an unsigned long long 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) |