std::pair::pair
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. |
| pair(); constexpr pair(); |
(1) | (jusqu'à C++11) (depuis C++11) |
| pair( const T1& x, const T2& y ); |
(2) | |
| template< class U1, class U2 > pair( U1&& x, U2&& y ); |
(3) | (depuis 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) | (depuis C++11) |
| template< class... Args1, class... Args2 > pair( std::piecewise_construct_t, |
(6) | (depuis C++11) |
| pair( const pair& p ) = default; |
(7) | |
| pair( pair&& p ) = default; |
(8) | (depuis C++11) |
Construit une nouvelle paire .
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.
Constructeur par défaut. Valeur-initialise les deux éléments de la paire, et
2) first 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.
Initialise
3) first avec x et second avec 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.
Initialise
4) first avec std::forward<U1>(x) et second avec 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.
Initialise
5) first avec p.first et second avec 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.
Initialise
6) first avec std::move<U1>(p.first) et second avec 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.
Transmet les éléments de
7) first_args au constructeur de first et transmet les éléments de second_args au constructeur de second. C'est le seul non-constructeur par défaut qui peut être utilisé pour créer une paire de non copiables non mobiles types .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.
Constructeur de copie est implicitement généré .
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.
Déplacer constructeur est implicitement généré .
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.
[modifier] Paramètres
| x | - | pour initialiser la valeur du premier élément de cette paire
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 | - | pour initialiser la valeur du second élément de cette paire
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 | - | Combinaison de valeurs utilisées pour initialiser les éléments de cette paire
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 | - | uplet d'arguments de constructeur pour initialiser le premier élément de cette paire
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 | - | uplet d'arguments de constructeur pour initialiser le second élément de cette paire
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. |
[modifier] Exemple
#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'; }
Résultat :
Value-initialized: 0, 0 Initialized with two values: 42, 0.123 Implicitly converted: *, 0 Piecewise constructed: (0.123,7.7), aaaaaaaaaa
[modifier] Voir aussi
| crée un objet de type pair, définie par le type des argumentsOriginal: 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. (fonction générique) | |