| Jon Stewart on 14 Oct 2003 06:27:11 -0000 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| [ALACPP] where the boost meets the stl |
Okay, so this does what I want:
#include <vector>
#include <iterator>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
using namespace std;
using namespace boost::lambda;
void foo(void) {
vector<int> vec;
int i(0);
generate_n(back_inserter(vec), 20, ++var(i));
}
Namely, it fills the vector with the numbers 1..20.
My question is, how can you do the same thing with std::fill_n, given its
prototype:
template<class OutIt, class Size, class T>
void fill_n(OutIt first, Size n, const T& x);
??
For reference purposes, generate_n works as such:
template<class OutIt, class Size, class Gen>
void generate_n(OutIt first, Size n, Gen g);
*(first + N) = g(); // for each N in [0, n)
Jon
--
Jon Stewart Advanced Los Angeles C++
stew1@xxxxxxxxxxx http://www.alacpp.org
_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp