std::pair::pair
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
pair(); constexpr pair(); | (1) | (fino al c++11) (dal C++11) |
pair(const T1& x, const T2& y ); | (2) | |
template<class U1, class U2 > pair( U1&& x, U2&& y ); | (3) | (dal C++11) |
template<class U1, class U2 > pair(const pair<U1,U2>& p ); | (4) | |
template<class U1, class U2 > pair( pair<U1,U2>&& p ); | (5) | (dal C++11) |
template<class... Args1, class... Args2> pair( std::piecewise_construct_t, | (6) | (dal C++11) |
pair(const pair& p )=default; | (7) | |
pair( pair&& p )=default; | (8) | (dal C++11) |
Costruisce una nuova coppia.
1) Original:
Constructs a new pair.
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.
Costruttore di default. Valore-inizializza entrambi gli elementi della coppia,
2) first
e second
.Original:
Default constructor. Value-initializes both elements of the pair,
first
and second
.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.
Inizializza
3) first
con x
e second
con y
.Original:
Initializes
first
with x
and second
with y
.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.
Inizializza
4) first
con std::forward<U1>(x) e second
con std::forward<U2>(y).Original:
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.
Inizializza
5) first
con p.first
e second
con p.second
. Original:
Initializes
first
with p.first
and second
with p.second
. 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.
Inizializza
6) first
con std::move<U1>(p.first) e second
con std::move<U2>(p.second).Original:
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.
Contratti a termine gli elementi della
7) first_args
al costruttore di first
e inoltra gli elementi della second_args
al costruttore di second
. Questo è l'unico costruttore non predefinito che può essere utilizzato per creare una coppia di non-copiabili non mobili tipi.Original:
Forwards the elements of
first_args
to the constructor of first
and forwards the elements of second_args
to the constructor of second
. This is the only non-default constructor that can be used to create a pair of non-copyable non-movable types.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.
Costruttore di copia è implicitamente generato.
8) Original:
Copy constructor is implicitly generated.
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.
Costruttore Move è implicitamente generato.
Original:
Move constructor is implicitly generated.
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.
[modifica]Parametri
x | - | valore per inizializzare il primo elemento di questa coppia Original: value to initialize the first element of this pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
y | - | valore per inizializzare il secondo elemento di questa coppia Original: value to initialize the second element of this pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
p | - | coppia di valori utilizzati per inizializzare entrambi gli elementi di questa coppia Original: pair of values used to initialize both elements of this pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
first_args | - | tupla di argomenti del costruttore per inizializzare il primo elemento di questa coppia Original: tuple of constructor arguments to initialize the first element of this pair The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
second_args | - | tupla di argomenti del costruttore per inizializzare il secondo elemento di questa coppia Original: tuple of constructor arguments to initialize the second element of this pair 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 <utility>#include <string>#include <complex>#include <tuple>#include <iostream>int main(){std::pair<int, float> p1;std::cout<<"Value-initialized: "<< p1.first<<", "<< p1.second<<'\n'; std::pair<int, double> p2(42, 0.123);std::cout<<"Initialized with two values: "<< p2.first<<", "<< p2.second<<'\n'; std::pair<char, int> p4(p2);std::cout<<"Implicitly converted: "<< p4.first<<", "<< p4.second<<'\n'; std::pair<std::complex<double>, std::string> p6( std::piecewise_construct, std::forward_as_tuple(0.123, 7.7), std::forward_as_tuple(10, 'a'));std::cout<<"Piecewise constructed: "<< p6.first<<", "<< p6.second<<'\n';}
Output:
Value-initialized: 0, 0 Initialized with two values: 42, 0.123 Implicitly converted: *, 0 Piecewise constructed: (0.123,7.7), aaaaaaaaaa
[modifica]Vedi anche
crea un oggetto di tipo pair , definita dai tipi di argomentiOriginal: creates a pair object of type, defined by the argument typesThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) |