I am new to boost and trying to write some simple programs to understand it. Here in the following piece of code I am trying to fill an array with random numbers. Here is my code:
using namespace boost::lambda;
srand(time(NULL));
boost::array<int,100> a;
std::for_each(a.begin(), a.end(), _1=rand());
But it looks like rand()
is getting evaluated only once and my array is containing the same values for every element. Can anybody point what is wrong with this code?