#include <iostream>
#include <random>
#include <algorithm>
int main()
{
std::mt19937 mt;
std::uniform_int_distribution<int> d(0, 255);
int l = 500;
std::vector<int> k(l);
std::generate(k.begin(), k.end(), d(mt));
return(0);
}
试图用两者来编译,g++ 4.7.2
就像g++ 4.8.1
这样
g++ -std=c++11 main.cpp
报告的错误是
In file included from /usr/include/c++/4.7/algorithm:63:0,
from main.cpp:3:
/usr/include/c++/4.7/bits/stl_algo.h: In instantiation of ‘void std::generate(_FIter, _FIter, _Generator) [with _FIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Generator = int]’:
main.cpp:11:42: required from here
/usr/include/c++/4.7/bits/stl_algo.h:5083:2: error: ‘__gen’ cannot be used as a function
对于这种情况下可能出现的问题,我没有任何线索或想法。