I try to understand why my code gives a compilation error. I've made a minimal example that keep same behaviour / architecture and error than the code in my project. The goal is to made a parallel evaluation of object in a vector.
template < class InputIterator, class OutputIterator > void evaluate( InputIterator first, InputIterator last, OutputIterator outfirst ) { while( first != last ) { *outfirst++ = (*first++) / 2 ; // only for the example } } template < int num_t = 4 > struct ParallelEvaluator { template< typename InputContainer , typename OutputContainer > static void eval(InputContainer const & src, OutputContainer & dst) { std::vector<std::thread> threads ; auto bg = src.begin() ; auto bg_r = dst.begin() ; for ( int i = 0 ; i < num_t ; i++ ) { threads.push_back(std::thread(evaluate<typename InputContainer::iterator,typename OutputContainer::iterator> ,bg,bg+4,bg_r)) ; bg = bg+4 ; bg_r = bg_r + 4 ; } std::for_each(threads.begin(),threads.end(),std::mem_fn(&std::thread::join)); } }; int main() { std::vector<int> t = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15} ; std::vector<int> v(16) ; ParallelEvaluator<4>::eval(t,v) ; return 0; } When I try to compile this code I get the following error :
/usr/include/c++/4.8/functional:1697: error: no type named 'type' in 'class std::result_of<void (*(__gnu_cxx::__normal_iterator<const int*, std::vector<int> >, __gnu_cxx::__normal_iterator<const int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> >))(__gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> >, __gnu_cxx::__normal_iterator<int*, std::vector<int> >)>' I saw that kind of error occurs when reference are using in the thread callback but it is not the case here.
Does somebody know why this error occurs ? Do I need a specific syntax to use template and co ?
Thanks
threads.push_back(...)evaluate<:::>is a function...