Fill
void fill(first, last, value);
Funkcja przypisuje podaną wartość value wszystkim elementom z zakresu [first, last).
Przykład
#include <iostream> #include <algorithm> #include <vector> int main() { std::vector<int> v; v.push_back(0); v.push_back(1); v.push_back(2); v.push_back(3); // ładnie nam wyświetli na cout cały wektor std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " ")); std::fill(v.begin(), v.end(), 0); // a teraz same zera std::copy(v.begin(), v.end(), std::ostream_iterator<int>(std::cout, " ")); }
Zobacz też: