Results 1 to 2 of 2

Thread: Reduce Functor in QtConcurrent::mappedReduced

  1. #1
    Join Date
    Dec 2008
    Location
    Cali, Colombia
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Reduce Functor in QtConcurrent::mappedReduced

    Hi,

    I want to use QtConcurrent::mappedReduced with only Functors but compiler says:

    Qt Code:
    1. 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:

    Qt Code:
    1. struct MapS
    2. {
    3. typedef int result_type;
    4.  
    5. int operator()( int v )
    6. {
    7. return v;
    8. }
    9. };
    10.  
    11. struct ReduceS
    12. {
    13. typedef int result_type;
    14. void operator()( int & r, const int & v )
    15. {
    16. r+=v;
    17. }
    18. };
    19.  
    20. int main( int argc, char ** argv )
    21. {
    22. QVector<int> vector( 1024, 1 );
    23. for( int i = 0; i < vector.count(); ++i )
    24. vector[i]=i+1;
    25.  
    26. qDebug() << QtConcurrent::mappedReduced( vector.constBegin(), vector.constEnd(), MapS(), ReduceS() );
    27.  
    28. return 0;
    29. }
    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.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Reduce Functor in QtConcurrent::mappedReduced

    try const int &r for the reducer's first arg?

Similar Threads

  1. is it possible to reduce the static exe file size?
    By mismael85 in forum Installation and Deployment
    Replies: 1
    Last Post: 17th April 2008, 00:18
  2. how to reduce the size of qt/e application
    By sar_van81 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 16th August 2007, 15:19
  3. Reduce the size of Qt-compiled software
    By ct in forum Qt Programming
    Replies: 7
    Last Post: 2nd May 2007, 14:05
  4. Replies: 4
    Last Post: 19th April 2007, 13:17

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.