STL之fill和fill_n函式
阿新 • • 發佈:2019-02-03
template <class ForwardIterator, class T> void fill(ForwardIterator first, ForwardIterator last, const T &value) { for(; first != last; ++first) *first = value; } template <class OutputIterator, class Size, class T> OutputIterator fill_n(OutputIterator first, Size n, const T &value) { for(; n > 0; --n, ++first) *first = value; return first; }