繁体   English   中英

无法编译函子模板

[英]Unable to compile a functor template

我正在尝试定义一个功能

template<typename Functor> static void start(DataSize size, ThreadNum threadNum, Functor f)
{
    ....

    std::for_each<int>(allocated, size, f);

    ....
}

分配和大小只是整数。

调用方调用该函数

start(image.width() * image.height(), _threads, RGBHistogramFun<T>(image, hist));

template<typename T> class RGBHistogramFun
{
    ...

    void operator()(std::size_t i)
    {
        ....
    }
}

我将模板的T设置为int。 我正在尝试定义std :: for_each,以便它为每个从分配给大小的整数调用RGBHistogramFun :: operator(std :: size_t i)。 operator()将使用索引来操纵其内部数组数据。

但是,我收到有关xutility的编译器错误。

n3337 25.2.4

template<class InputIterator, class Function>
Function for_each(InputIterator first, InputIterator last, Function f);

效果:将f应用于解引用从[first,last]开始到最后-1范围内的每个迭代器结果

dereferenced int

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM