0

我正在使用 parallel_for_each 并行化一个 for 循环(迭代一个 stl 列表),但我得到一个编译时错误,说没有匹配的函数调用。

//TBB headers
#include "tbb/parallel_for_each.h"

class FUNCTOR
{
public:
    FUNCTOR(    
        CLASS_A& tree,
        CLASS_B *groups,
        const CLASS_C** default_dominator,
        const CLASS_D& filter
    ):
        tree(tree),
        groups(groups),
        default_dominator(default_dominator),
        filter(filter)
    {}
            // Iterator dereferences to a pointer
    void operator()(const ELEMENT_OF_LIST_A*& keeper) const
    {
        /*something*/
    }

private:
    CLASS_A& tree;
    CLASS_B *groups;
    const CLASS_C** default_dominator;
    const CLASS_D& filter;
};


void some_function
(
    CLASS_A& tree,
    CLASS_B *groups,
    const CLASS_C** default_dominator,
    const LIST_A& keepers,
    const CLASS_D& filter
)
{
    // Some code that claims processors

    //LIST_A_ITER begin = keepers.begin();
    //LIST_A_ITER end = keepers.end();
    //const ELEMENT_OF_LIST_A* keeper = *begin

    tbb::parallel_for_each
    (
        keepers.begin(), keepers.end(),
        FUNCTOR(    
            tree,
            groups,
            default_dominator,
            filter
        )
    );

}

我得到的错误是:

error: no matching function for call to 'tbb::internal::parallel_do_operator_selector<tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>::call(const tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>&, ELEMENT_OF_LIST_A*, tbb::internal::do_iteration_task_iter<LIST_A_ITER, tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>::feeder_type&)'


note: candidate is: static void tbb::internal::parallel_do_operator_selector<Body, Item>::call(const Body&, A1&, A2&) [with A1 = ELEMENT_OF_LIST_A*, A2 = tbb::internal::parallel_do_feeder_impl<tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, ELEMENT_OF_LIST_A*>, Body = tbb::internal::parallel_for_each_body<FUNCTOR, LIST_A_ITER>, Item = ELEMENT_OF_LIST_A*]

什么地方出了错?

谢谢!

4

1 回答 1

0

FUNCTOR 的 operator() 具有额外的间接级别。不带 * 声明它,例如:

const ELEMENT_OF_LIST_A& keeper
于 2013-08-07T14:10:14.967 回答