0

我试图在 Visual Studio中使用OMPTL 。据我了解,我只需要设置 /openmp 选项,以便 OMPTL 使用一些 stl 函数的多线程实现。

当我不使用 /openmp 时,一切都很好,并且 OMPTL 将函数映射到它们的正常 stl 计数器部分,而无需多线程。然而,使用 /openmp,我得到一个编译器错误:

Error 1 error C2572: 'omptl::transform_accumulate' : redefinition of default parameter : parameter 6 ..\include\omptl\omptl_numeric_extentions_par.h 132

有问题的行说

template <class Iterator, class T, class UnaryFunction, class BinaryFunction>
T transform_accumulate(Iterator first, Iterator last, const T init,
   UnaryFunction unary_op, BinaryFunction binary_op,
   const unsigned P = omp_get_max_threads())
{
 return ::omptl::_TransformAccumulate
 <typename ::std::iterator_traits<Iterator>::iterator_category>
  ::transform_accumulate(first, last, init,
     unary_op, binary_op, P);
}

有没有办法解决这个问题,或者 OMPTL 根本不能与微软的编译器一起使用?

4

1 回答 1

0

编译器似乎不接受此模板声明中的默认参数。从两个声明中删除= omp_get_max_threads()为我解决了这个问题。

于 2010-09-28T13:38:35.537 回答