title: Using C++11 lambda functions in ARC ObjectiveC++ - how to do it properly?
body: <p>I have an ObjectiveC++ project. In the ObjectiveC context I am using ARC and iPhoneSDK 6. In C++ I am using a C++11 compiler.</p>
  
  <p>Lambda functions in C++11 are capturing variables with references. This concept is not really supported by ObjectiveC and by "try and error" I came up with the following solution. Are there any pitfalls I am not aware of?</p>
  
  <p>Is there a better solution to this problem?</p>
  
  <pre><code>typedef std::function&lt;void ()&gt; MyLambdaType;
  
  ...
  // m_myView will not go away. ARC managed.
  UIView * __strong m_myView;
  
  ...
  // In Objective C context I create a lambda function that calls my Objective C object
  UIView &amp;myViewReference = *m_myView;
  MyLambdaType myLambda = [&amp;myViewReference]() {
      UIView *myViewBlockScope = &amp;myViewReference;
      // Do something with `myViewBlockScope`
  }
  
  ..
  // In C++11 context I call this lambda function
  myLambda();
  </code></pre>