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 6635079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:00:24+00:00 2026-05-25T23:00:24+00:00

Here is some sample code that illustrates the problem. It compiles and runs correctly,

  • 0

Here is some sample code that illustrates the problem.
It compiles and runs correctly, but the VS2010 editor IntelliSense complains about the hold variable and shows the following message

IntelliSense: a nonstatic member reference must be relative to a
specific object

class tester
{
public:
    void test()
    {
        int outer[] = {1,2,3};
        int inner[] = {4,5,6};
        std::for_each(outer, outer + _countof(outer), [&](int o) {
            std::for_each(inner, inner + _countof(inner), [&](int i) {
                hold.push_back(i + o);
            });
        });
    }
private:
    std::vector<int> hold;
};

int main(int argc, char* argv[])
{
    tester().test();
    return 0;
}

NB: It is happy if there is only one level of for_each (just outer for example)

Has anyone else come across this, and if so, is there a way to change it slightly so that the IntelliSense is happy or am I stuck with red squiggly lines?

UPDATE:
I have downloaded the preview of VS11 it is happy with the code – no squiggly lines, so at least it has been fixed for the next release.

  • 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-25T23:00:24+00:00Added an answer on May 25, 2026 at 11:00 pm

    If you are just looking for a workaround to placate VS2010’s intellisense, you can capture hold in the outer lambda like this:

    std::for_each(outer, outer + _countof(outer), [&](int o) {
        auto &hold = this->hold; // capturing hold to avoid intellisense reporting an "error"
        std::for_each(inner, inner + _countof(inner), [&](int i) {
            hold.push_back(i + o);
        });
    });
    

    Explicitly define hold’s type or rename the variable for clarity as you feel is appropriate (using auto and name hiding due to laziness).

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

Sidebar

Related Questions

Here is an abstract JavaScript code sample that illustrates the situation that is causing
Here is some sample code to illustrate the problem I am having. #include <iostream>
Here's some sample code that I want to control using jQuery (white button bg
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater:
I'm looking for some sample code that will sort the list items in an
I've seen some sample code that does this: proc_entry->read_proc = module_read; proc_entry->write_proc = module_write;
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
here is some sample javascript: SomeObjectType = function() { } SomeObjectType.prototype = { field1:
This is similar to (but different from) this question . Here is some simple

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.