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

  • SEARCH
  • Home
  • 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 7873027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:23:31+00:00 2026-06-03T02:23:31+00:00

I am using PPL and parallel_for syntax to have a for loop. In the

  • 0

I am using PPL and parallel_for syntax to have a for loop. In the capture clause, I have 3 variables, one of them is a class member. There is a compilation error due to the presence of a class member among variables in the capture clause. However, if I have this class member in lambda body, it does not compile either, and error stated is that variable in enclosing scope should be in capture clause. How to proceed? Should I copy the variable member to a local variable beforehand, and have it passed in the capture clause?

Here is the code, with formulaCommand the class member.

parallel_for (m_rowStart,m_rowEnd+1,[&functionEvaluation,varModel_,formulaCommand](int i)
    {       
            MLEquationVariableModel  model_(varModel_);
            model_.addVariable("i", i);
            model_.addVariable("j", 1);
            MLEquationCommand* command_ = formulaCommand->duplicate(&model_);
            double d = command_->execute().toDouble();
            if(d==NO_VALUE)
            {
                functionEvaluation.local()  = NO_VALUE;
            }
            else
            {
                functionEvaluation.local() += d;
            }
            delete command_;
    });

Thanks!

  • 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-06-03T02:23:33+00:00Added an answer on June 3, 2026 at 2:23 am

    You need to capture this to access the member variables (remember that formulaCommand is equivalent to this->formulaCommand).

    [&functionEvaluation, varModel_, this](int i) { ... }
    

    (BTW, you should probably use a smart pointer (unique_ptr<MLEquationCommand>) instead of manually delete-ing the raw pointer command_.)

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

Sidebar

Related Questions

I have a simple container class with a copy constructor. Do you recommend using
using Backbone.js we have an application, in which on a certain occasion we need
Using msi engine (newer than 3) on Windows (XP+, 7, 2k3): Is there a
Using jQuery, I am trying to capture and display the value of a div
Using JSF2 and richfaces 4. I have two regions in my form with multiple
I have created my entire website by using a main table, and having the
A domain name that we have is using google mail as its backend, but
I am using a Download Class which i found here http://www.phpclasses.org/package/3220-PHP-Serve-files-for-download-with-resume-support.html to let ppl
Using mercurial, I've run into an odd problem where a line from one committer
I'm looking for a concurrent cache structure. I'm using the PPL from Microsoft so

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.