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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:06:15+00:00 2026-06-11T02:06:15+00:00

I can get the following code to compile: enum E {a, b, c}; void

  • 0

I can get the following code to compile:

enum E {a, b, c};
void f()
{
    E e;
    std::function<void()> f = [&]() { e = a; };
} 

but not the following one:

void f()
{
    enum E {a, b, c};
    E e;
    std::function<void()> f = [&]() { e = a; };
} 

which issues the following compiler error:

1>test.cpp(5): error C2665: '`anonymous-namespace'::<lambda1>::<lambda1>' : none of the 2 overloads could convert all the argument types
1>          test.cpp(5): could be '`anonymous-namespace'::<lambda1>::(f::E &,f::E &)'
1>          while trying to match the argument list '(f::E, f::E)'

Is that error expectable or is it a bug?

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

    This appears identical to the issue at http://social.msdn.microsoft.com/Forums/en/vclanguage/thread/88f533d8-b7f5-4416-bdcf-b461aeb74178. As there, it appears to be a bug in the compiler. MSVC appears to have a few issues with local types in lambdas; see also http://connect.microsoft.com/VisualStudio/feedback/details/675113/lambda-expression-causes-internal-compiler-error#details.

    There is no language in 5.1.2 Lambda expressions [expr.prim.lambda] to say that locally-defined types cannot be captured in a lambda.

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

Sidebar

Related Questions

Given the following code which I can't get to compile. template < typename OT,
I have the following code, but I can't get it to work. As soon
I have the following code; http://pastebin.com/Wf598D2E But I can't get distance value to #result
The following code does not compile: #include <iostream> class Foo { std::string s; public:
I am trying to get the following code to compile but am getting errors
When I compile the following code using g++ class A {}; void foo(A&) {}
I'm trying to use the following code, but can't get it to complete. Can
Can anyone explain why the following code does not compile (on g++ (GCC) 3.2.3
I can't seem to get the following trivial code to compile/link and the problem
If I have the following code in a function, I will not get an

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.