5. Lambdas
auto f = [&n](int i)
{ return i + n };
Making the simplest lambda
[](){}
a method that captures nothing, is passed no arguments, and does nothing.
• Neat and readable
• Inline in code
• Inlineable and performant
• Capture variables by value or reference
• Behave like an object
6. Smart Pointers
No:
Foo* foo = new Foo();
__try {
//
} __finally {
delete foo;
}
Yes:
{
unique_ptr<Foo> foo(
new Foo());
}
^- foo is freed
11. Q&A and Resources – C++ talk next up!
• Basics: Books! http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list and forums like the C
++ G+ group: https://plus.google.com/u/0/communities/116007775542700637383 (general C++) or https://
plus.google.com/communities/118315259185736124693 (C++Builder)
• C++ / STL: http://cppreference.com
• Auto: http://thbecker.net/articles/auto_and_decltype/section_01.html
• Lambdas: http://www.drdobbs.com/cpp/lambdas-in-c11/240168241
• Smart pointers: http://www.acodersjourney.com/2016/05/top-10-dumb-mistakes-avoid-c-11-smart-pointers/
• C++ Builder
• http://docwiki.embarcadero.com/RADStudio/Berlin/en/C++11_Language_Features_Compliance_Status
• http://docwiki.embarcadero.com/RADStudio/Berlin/en/C++11_Features_Supported_by_RAD_Studio_Clang-
enhanced_C++_Compilers
https://www.facebook.com/cppbuilder and https://twitter.com/EmbarcaderoTech
Under the hood of the C++ compiler and IDE:
a conversation with Patrick Scheller and Bruneau Babet
is up next, right after the Q&A!