std::fill
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. | 
| Defined in header <algorithm>
  | ||
| template< class ForwardIt, class T > void fill( ForwardIt first, ForwardIt last, const T& value ); | ||
Assegna il 
value data agli elementi della gamma [first, last).Original:
Assigns the given 
value to the elements in the range [first, last).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.
| Indice | 
[modifica] Parametri
| first, last | - |  l'intervallo di elementi da modificare Original:  the range of elements to modify The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | 
| value | - |  il valore da assegnare Original:  the value to be assigned The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | 
| Type requirements | ||
| - ForwardItmust meet the requirements ofForwardIterator. | ||
[modifica] Valore di ritorno
(Nessuno)
Original:
(none)
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] Complessità
Esattamente 
last - first incarichi.Original:
Exactly 
last - first assignments.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] Possibile implementazione
| template< class ForwardIt, class T > void fill(ForwardIt first, ForwardIt last, const T& value) { for (; first != last; ++first) { *first = value; } } | 
[modifica] Esempio
 Il codice seguente utilizza 
fill() per impostare tutti gli elementi di un vettore di interi a -1: 
 Original:
 The following code uses 
fill() to set all of the elements of a vector of integers to -1: 
 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 <algorithm> #include <vector> #include <iostream> int main() { int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } std::vector<int> v1(data, data+10); std::fill(v1.begin(), v1.end(), -1); for (vector<int>::iterator it = v1.begin(); it != v1.end(); ++it) { std::cout << *it << " "; } std::cout << "\n"; }
Output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1
[modifica] Vedi anche
|  assegna un valore a un numero di elementi  Original:  assigns a value to a number of elements  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
|  salva il risultato di una funzione in un intervallo  Original:  saves the result of a function in a range  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |
|  applica una funzione di una serie di elementi  Original:  applies a function to a range of elements  The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) | |


