[Interest] QtConcurrent::mappedReduced

Michael Sué sue at sf.mpg.de
Thu Apr 20 11:47:50 CEST 2017


Hi,

two questions:

1) should the following code compile

QVector<int> slices;
QFuture<bool> result=QtConcurrent::mappedReduced<bool>(slices,
[=](const int iSlice) -> bool {
	bool ok=true
	//....
	return ok;
},
[=](bool &endok, const bool ok) {
	endok= endok && ok;
},
QtConcurrent::UnorderedReduce);

QFutureWatcher<bool> futureWatcher;
futureWatcher.setFuture(result);
bool ok=result.result();

with VS 2015 it produces a lot of template based error messages; see below. 

Or maybe someone sees what's wrong with the code?

2) How to initialize endok in the second lambda function. 

Or should I always work with two functors and use their operator()? That way it compiles and works without problem.

Best, Michael.


VS output:

1>E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(124): error C2039: 'result_type': is not a member of 'VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>'
1>  saveecat7image.cpp(405): note: see declaration of 'VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>'
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(123): note: while compiling class template member function 'bool QtConcurrent::MappedReducedKernel<ResultType,Iterator,MapFunctor,ReduceFunctor,Reducer>::runIterations(Iterator,int,int,ReducedResultType *)'
1>          with
1>          [
1>              ResultType=bool,
1>              MapFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>,
1>              Iterator=Iterator,
1>              ReducedResultType=bool
1>          ]
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentreducekernel.h(222): note: see reference to class template instantiation 'QtConcurrent::MappedReducedKernel<ResultType,Iterator,MapFunctor,ReduceFunctor,Reducer>' being compiled
1>          with
1>          [
1>              ResultType=bool,
1>              MapFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>
1>          ]
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(247): note: see reference to class template instantiation 'QtConcurrent::SequenceHolder2<Sequence,MappedReduceType,MapFunctor,ReduceFunctor>' being compiled
1>          with
1>          [
1>              Sequence=QVector<int>,
1>              MapFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>
1>          ]
1>  e:\qt\5.8.0\include\qtconcurrent\qtconcurrentmap.h(130): note: see reference to function template instantiation 'QtConcurrent::ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced<void,ResultType,Sequence,T,VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>>(const Sequence &,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)' being compiled
1>          with
1>          [
1>              ResultType=bool,
1>              Sequence=QVector<int>,
1>              T=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              MapFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>
1>          ]
1>  saveecat7image.cpp(407): note: see reference to function template instantiation 'QFuture<bool> QtConcurrent::mappedReduced<bool,QVector<int>,VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>>(const Sequence &,MapFunctor,ReduceFunctor,QtConcurrent::ReduceOptions)' being compiled
1>          with
1>          [
1>              Sequence=QVector<int>,
1>              MapFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_0f3d108deaf8f65a4fde0410cc7b1c01>,
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>
1>          ]
1>E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(124): error C2146: syntax error: missing '>' before identifier 'result_type'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(73): error C2182: 't': illegal use of type 'void'
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentreducekernel.h(82): note: see reference to class template instantiation 'QVector<void>' being compiled
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(136): note: see reference to class template instantiation 'QtConcurrent::IntermediateResults<T>' being compiled
1>          with
1>          [
1>              T=void
1>          ]
1>E:\Qt\5.8.0\include\QtCore/qvector.h(134): error C2182: 'at': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(135): error C2182: '[]': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(136): error C2182: '[]': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(137): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(139): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(142): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(143): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(144): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(145): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(153): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(155): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(156): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(157): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(158): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(162): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(174): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(228): error C2182: 'x': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(229): error C2182: 'x': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(235): error C2182: 'first': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(236): error C2182: 'first': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(237): error C2182: 'constFirst': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(238): error C2182: 'last': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(239): error C2182: 'last': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(240): error C2182: 'constLast': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(241): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(242): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(246): error C2182: 'defaultValue': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(252): error C2182: 'reference': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(253): error C2182: 'const_reference': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(258): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(260): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(262): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(267): error C2182: 'front': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(276): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtCore/qvector.h(278): error C2182: 't': illegal use of type 'void'
1>E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(136): error C2664: 'void QtConcurrent::ReduceKernel<ReduceFunctor,ResultType,IntermediateType>::runReduce(ReduceFunctor &,ReduceResultType &,const QtConcurrent::IntermediateResults<T> &)': cannot convert argument 3 from 'QtConcurrent::IntermediateResults<int>' to 'const QtConcurrent::IntermediateResults<T> &'
1>          with
1>          [
1>              ReduceFunctor=VSaveECAT7Image::saveSpecificFileFormat::<lambda_51b6a89f71fc49f22b1133cd7f4b91a2>,
1>              ResultType=bool,
1>              IntermediateType=void,
1>              ReduceResultType=bool,
1>              T=void
1>          ]
1>          and
1>          [
1>              T=void
1>          ]
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(136): note: Reason: cannot convert from 'QtConcurrent::IntermediateResults<int>' to 'const QtConcurrent::IntermediateResults<T>'
1>          with
1>          [
1>              T=void
1>          ]
1>  E:\Qt\5.8.0\include\QtConcurrent/qtconcurrentmapkernel.h(136): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called




More information about the Interest mailing list