为什么std :: generate可以与lambda generator一起使用,而std :: fill却不能呢?

Pat*_*ryk 0 c++ lambda std

我偶然发现了以下网站:http : //www2.research.att.com/~bs/C++0xFAQ.html#lambda,他们在其中解释了lambda函数。我尝试使用提供的示例:

    vector<int> indices( notImportantNumber );
    int count = 0;
    fill(indices.begin(), indices.end(), [&](){ return ++count; });
Run Code Online (Sandbox Code Playgroud)

同样

    generate(indices.begin(), indices.end(), [&](){ return ++count; });
Run Code Online (Sandbox Code Playgroud)

虽然,当我尝试将示例与fill一起使用时,我继续遇到此错误:

错误1错误C2440:'=':无法从'const`anonymous-namespace'::'转换为'long'c:\ program files \ microsoft visual studio 10.0 \ vc \ include \ xutility 2692

有人知道为什么会这样吗?在的声明中std::fill(),没有函子作为最后一个参数。

Cat*_*lus 5

该网站上的错误。std::fill需要一个值来填充,而不是可调用的。