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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:42:03+00:00 2026-06-17T12:42:03+00:00

I have a problem with a nested lambda function which cannot see a static

  • 0

I have a problem with a nested lambda function which cannot see a static class member. Visual Studio 2010 gives me a C2065 ( undeclared identifier ) for reasons I cannot understand.

Here is simple case that highlights my problem:

#include <algorithm>
#include <vector>

using namespace std;

struct foo
{
    void do_some()
    {
        std::vector<int> a;
        std::vector<int> b;

        for_each( a.begin(), a.end(), [&] ( const int& m )
            {
                // works
                auto j = _i + 1;

                for_each( b.begin(), b.end(), [&] ( const int& n )
                    {
                        **// doesn't work**
                        auto k = _i + 1;
                    } );
            } );
    }

    static int _i;
};

int main(int argc, char* argv[])
{
}

Anyone knows what I’m doing wrong?

Thanks,
Christian

  • 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-17T12:42:04+00:00Added an answer on June 17, 2026 at 12:42 pm

    Probably a compiler bug (fixed in VC++ 2012). This works:

    auto k = ::foo::_i + 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have awkward problem I cannot resolve. I have a nested divs, which I
I have a Java problem with nested classes. My first class structure looked like
I have a problem with nested routes which don't display correct url. I use
I have a problem with nested divs, and jQuery's click function. Clicking on .header-fb,
I have a problem with nested templates and their template specialization. Given the following
I'm having a problem with nested bindings with Knockout.JS For example if I have
I have this problem: After instantiating this Window, open all nested expanders on the
Is it possible to tie nested generics/captures together? I often have the problem of
I have a table with a tags nested inside the td tags. Problem is,
I'm having a problem with some for nested loops that I have to convert

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.