Hi,
I want to use QtConcurrent::mappedReduced with only Functors but compiler says:
error: no matching function for call to ‘mappedReduced(const int*, const int*, MapS, ReduceS)’
error: no matching function for call to ‘mappedReduced(const int*, const int*, MapS, ReduceS)’
To copy to clipboard, switch view to plain text mode
the map functor works but the reducer not.
the code is:
struct MapS
{
typedef int result_type;
int operator()( int v )
{
return v;
}
};
struct ReduceS
{
typedef int result_type;
void operator()( int & r, const int & v )
{
r+=v;
}
};
int main( int argc, char ** argv )
{
QVector<int> vector( 1024, 1 );
for( int i = 0; i < vector.count(); ++i )
vector[i]=i+1;
qDebug() << QtConcurrent::mappedReduced( vector.constBegin(), vector.constEnd(), MapS(), ReduceS() );
return 0;
}
struct MapS
{
typedef int result_type;
int operator()( int v )
{
return v;
}
};
struct ReduceS
{
typedef int result_type;
void operator()( int & r, const int & v )
{
r+=v;
}
};
int main( int argc, char ** argv )
{
QVector<int> vector( 1024, 1 );
for( int i = 0; i < vector.count(); ++i )
vector[i]=i+1;
qDebug() << QtConcurrent::mappedReduced( vector.constBegin(), vector.constEnd(), MapS(), ReduceS() );
return 0;
}
To copy to clipboard, switch view to plain text mode
so, is possible to use Functor Object as reduce functor? and how it must be defined?
Thanks.
Bookmarks