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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:47:40+00:00 2026-06-08T10:47:40+00:00

So, I just upgraded to Xcode 4.4, and I noticed in the changelog: Apple

  • 0

So, I just upgraded to Xcode 4.4, and I noticed in the changelog:

Apple LLVM compiler supports additional C++11 features, including lambdas

Which is awesome! So I got around to coding, and I found a few things out:

  1. Lambdas are assignable to Objective-C blocks:

    void (^block)() = []() -> void { 
        NSLog(@"Inside Lambda called as block!");
    };
    
    block();
    
  2. std::function can hold an Objective-C block:

    std::function<void(void)> func = ^{
        NSLog(@"Block inside std::function");
    };
    
    func();
    
  3. We cant assign an Objective-C block to a lambda:

    auto lambda = []() -> {
        NSLog(@"Lambda!");
    };
    
    lambda = ^{ // error!
        NSLog(@"Block!");
    };
    
    lambda();
    

Why is this? Shouldn’t the two be semantically equivalent, given what we’ve seen above?

  • 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-08T10:47:43+00:00Added an answer on June 8, 2026 at 10:47 am

    C++11’s lambda’s copy-assignment operator is explicitly disabled1. This is not a matter of “semantically equivalent”. It can’t even assign back to itself. Not to mention an unrelated type.

    #include <cstdio>
    #include <type_traits>
    
    int main() {
        auto lambda1 = []() -> void { printf("Lambda 1!\n"); };
        lambda1 = lambda1;  // error: use of deleted function ‘main()::<lambda()>& main()::<lambda()>::operator=(const main()::<lambda()>&)’
        return 0;
    }
    

    std::function can hold an Objective-C block.

    • std::function can hold any types which can be invoked as f(a,b,c,...). Since blocks support “the invoke operator”, it can also be held by a std::function. But notice that Objective-C and C++ follow different memory management scheme, so storing a block in a std::function for a long time may cause dangling reference.

    Lambdas are assignable to Objective-C blocks:

    • Blame SAHChandler2 :). It’s not documented yet, though.

    1: C++11 §5.1.2/19:

    The closure type associated with a lambda-expression has a deleted (8.4.3) default constructor and a deleted copy assignment operator.

    2: http://llvm.org/viewvc/llvm-project?view=rev&revision=150620

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

Sidebar

Related Questions

I just upgraded to Snow Leopard, including installing the new XCode, re-compiled Ruby 1.8
I just upgraded to Xcode 4.5 and noticed that my apps do not appear
Just upgraded my xcode to the latest SDK which has the iOS 4.1 SDK.
I just upgraded to the latest 4.3 Xcode. I have my plist.which is preprocessed
I just upgraded Xcode from 4.2 to 4.3.3. I then launches iOS Simulator (with
I just upgraded XCode to 4.3.2 and tried to load a project I am
I just upgraded to Xcode 3.2 and am using the Build and Analyze feature
I just upgraded my Xcode ide. I have 3 logins. In the logins I
I have just upgraded my XCode to 4.5 and installed the SDK 6.0. I
I just upgraded my Mac to Snow Leopard, and installed Xcode 3.2.3. The app

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.