Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:44:25+00:00 2026-05-26T22:44:25+00:00

From the QtConcurrent documentation : QByteArray bytearray = hello world; QFuture<QList<QByteArray> > future =

  • 0

From the QtConcurrent documentation:

QByteArray bytearray = "hello world";
QFuture<QList<QByteArray> > future = QtConcurrent::run(bytearray, &QByteArray::split), ',');
...
QList<QByteArray> result = future.result();

The code snippet above appears to be binding a function in a similar way to std::tr1::bind (std::bind for > C++11). That is to say it’s taking a non-static member function (QByteArray::split()) and (at some point later) calling it on the specific instance of the object of which it’s a member (which we’ve supplied as bytearray).

How does Qt achieve this? Is it using std::tr1::bind or boost::bind somewhere behind the scenes?

The documentation does also refer to a case where you would use std::tr1 or boost instead, but I don’t fully understand what it means by a bound function in that context. Is the situation above in fact different/more specialised/simpler than other situations where you might otherwise use tr1 or boost?

I’ve tried to make my way through the source but am getting lost very quickly!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:44:26+00:00Added an answer on May 26, 2026 at 10:44 pm

    I’m going to attempt a self answer, as the existing answers (many thanks to @Mike Brown and @skyhisi) lay the groundwork but don’t address this specific case…

    From the source:

    QtConcurrent::run(…) :

    template <typename T, typename Class>
    QFuture<T> run(const Class &object, T (Class::*fn)())
    {
      return (new QT_TYPENAME SelectStoredMemberFunctionCall0<T, Class>::type(fn, object))->start();
    }
    

    SelectStoredMemberFunctionCall0:

    template <typename T, typename Class>
    struct SelectStoredMemberFunctionCall0
    {
      typedef typename SelectSpecialization<T>::template
        Type<StoredMemberFunctionCall0    <T, Class>,
          VoidStoredMemberFunctionCall0<T, Class> >::type type;
    };
    

    VoidStoredMemberFunctionCall0:

    template <typename T, typename Class>
    class VoidStoredMemberFunctionCall0 : public RunFunctionTask<T>
    {
    public:
      VoidStoredMemberFunctionCall0(T (Class::*_fn)() , const Class &_object)
      : fn(_fn), object(_object){ }
    
      void runFunctor()
      {
        (object.*fn)();
      }
    private:
      T (Class::*fn)();
      Class object;
    };
    

    Given the above, I can see that Qt stores a pointer-to-member-function in the normal way, but by dressing it up in templates which would otherwise go unnoticed, the illusion of generic-ness is created.

    The type of VoidStoredMemberFunctionCall0::object as well as the signature of VoidStoredMemberFunctionCall0::fn are all specified above in the arguments passed to QtConcurrent::run.

    I wasn’t aware that this ‘implicit’ templatization was even possible, to be honest. Would anybody be able to recommend further reading?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From observing source code for various Android applications (not written by me), I noticed
From Java Malik textbook- determine if an number is divisible by 11.. Code Solution
From viewing the source code that this code makes it looks like itemValue generate
From the documentation of oracle : Domain Runtime MBean Server : This MBean server
From 19 Deadly Sins of Software Security ; The following code is the poster
From the Spring JDBC documentation, I know how to insert a blob using JdbcTemplate
From a web developer point of view, what changes are expected in the development
From a desktop application developer point of view, is there any difference between developing
From what I've read, VS 2008 SP1 and Team Foundation Server SP1 packages are
From time to time I see an enum like the following: [Flags] public enum

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.