fillの使い方


template < class ForwardIterator, class T >
  void fill ( ForwardIterator first, ForwardIterator last, const T& value );
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct info{
	int key;
	int value;
	info(int key,int value):key(key),value(value){}
	info():key(0),value(0){}
	bool operator=(info temp){
	key=temp.key;
	value=temp.value;
	}
};
int main(){
	vector<info>vec(2);
	info A(1,2);
	fill(vec.begin(),vec.end(),A);
	vector<info>::iterator it;
	for(it=vec.begin();it!=vec.end();it++)
		cout<<(*it).key<<"\t"<<(*it).value<<endl;

}
<algorithm>

Fill range with value
Sets value to all elements in the range [first,last).
The behavior of this function template is equivalent to:
template < class ForwardIterator, class T >
  void fill ( ForwardIterator first, ForwardIterator last, const T& value )
{
  while (first != last)  *first++ = value;
}

Parameters


first, last
Forward iterators to the initial and final positions in a sequence. The range affected is  [first,last), which contains all the elements between 
first and 
last, including the element pointed by 
first but not the element pointed by 
last.
value
Value to be used to fill the range.

Return value

none