ksrarc

12th June 2009, 18:22

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)â€™

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;

}

so, is possible to use Functor Object as reduce functor? and how it must be defined?

Thanks.

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)â€™

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;

}

so, is possible to use Functor Object as reduce functor? and how it must be defined?

Thanks.