std::ignore
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>| Definido no cabeçalho <tuple>
|
||
const /*unspecified*/ ignore; |
(desde C++11) | |
Um objeto do tipo não especificado de tal forma que qualquer valor pode ser atribuído a ele sem nenhum efeito. Projetado para uso com std::tie quando descompactar um std::tuple, como um espaço reservado para os argumentos que não são usados .
Original:
An object of unspecified type such that any value can be assigned to it with no effect. Intended for use with std::tie when unpacking a std::tuple, as a placeholder for the arguments that are not used.
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
desempacotar um par retornado por set.insert (), mas só guardar o booleano .
Original:
unpack a pair returned by set.insert(), but only save the boolean.
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.
#include <iostream>
#include <string>
#include <set>
#include <tuple>
int main()
{
std::set<std::string> set_of_str;
bool inserted;
std::tie(std::ignore, inserted) = set_of_str.insert("Test");
if (inserted) {
std::cout << "Value was inserted sucessfully\n";
}
}
Saída:
Value was inserted sucessfully
cria um tuple de referências lvalue ou desempacota a tupla em objetos individuaisOriginal: creates a tuple of lvalue references or unpacks a tuple into individual objectsThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de função) | |