C++ in the 21st Century

Mar. 19, 2014
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
C++ in the 21st Century
1 of 60

More Related Content

Similar to C++ in the 21st Century

C++ FunctionsC++ Functions
C++ Functionssathish sak
Kostiantyn Grygoriev "Wrapping C++ for Python"Kostiantyn Grygoriev "Wrapping C++ for Python"
Kostiantyn Grygoriev "Wrapping C++ for Python"LogeekNightUkraine
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
Gentle introduction to modern C++Gentle introduction to modern C++
Gentle introduction to modern C++Mihai Todor
Making archive IL2C #6-55 dotnet600 2018Making archive IL2C #6-55 dotnet600 2018
Making archive IL2C #6-55 dotnet600 2018Kouji Matsui
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOLiran Zvibel

Recently uploaded

Product Research Presentation-Maidy Veloso.pptxProduct Research Presentation-Maidy Veloso.pptx
Product Research Presentation-Maidy Veloso.pptxMaidyVeloso
Announcing InfluxDB ClusteredAnnouncing InfluxDB Clustered
Announcing InfluxDB ClusteredInfluxData
info_session_gdsc_tmsl .pptxinfo_session_gdsc_tmsl .pptx
info_session_gdsc_tmsl .pptxNikitaSingh741518
Cloud Composer workshop at Airflow Summit 2023.pdfCloud Composer workshop at Airflow Summit 2023.pdf
Cloud Composer workshop at Airflow Summit 2023.pdfLeah Cole
Framing Few Shot Knowledge Graph Completion with Large Language ModelsFraming Few Shot Knowledge Graph Completion with Large Language Models
Framing Few Shot Knowledge Graph Completion with Large Language ModelsMODUL Technology GmbH
Nymity Framework: Privacy & Data Protection Update in 7 StatesNymity Framework: Privacy & Data Protection Update in 7 States
Nymity Framework: Privacy & Data Protection Update in 7 StatesTrustArc

C++ in the 21st Century

Editor's Notes

  1. Feel free to interrupt if I’m wrong about something, if I have a bug or if you have a question. These are the features I will cover. I haven’t actually had time to proof read this very carefully, nor test all code snippets.
  2. 4 language features and 3 new library additions.
  3. One small but important new feature is the for loop. Vastly simplifies the common case to make it less error prone.
  4. the C and C++98 for loop. using iterators for STL containers and indices for arrays. imagine if the loop bodies were a bit bigger, your assumption about the for loop hinge on the body not modifying the iterator.
  5. C++11 adds a range-for loop. No iterator/counter. right of the colon is any container type satisfying the interface for a container, begin() and end() functions.
  6. The loop can be thought of expanding to something like this. The type of v must have two free functions begin() and end().
  7. explain argument dependent lookup. Introduced primarily for operator overloading, but is extremely useful for constructing compossible interfaces. The begin() and end() functions are looked for in the same namespace as the type of v is defined in.
  8. That’s how it works for C arrays. The standard library defines functions that can be thought of looking something like this
  9. automatic type deduction is another major feature in C++11, where you can leverage the compilers ability to deduce types
  10. auto can be used to specify “whatever type works here”. decltype() is a type-expression that can be used for template arguments for instance.
  11. decltype is used to produce the type of the return value of f().
  12. C++ introduces anonymous function objects, referred to as lambda functions. To understand what they are, let’s start at the beginning in 1998.
  13. find the first element in v that is divisible by a number (x). create a function object (note the function call operator). This object holds the state of the parameter x.
  14. in C++03 the bind function is introduced. It significantly simplifies binding values to functions. There is no longer a need to make the predicate function an object, it can be a plain function.
  15. bind introduces partially applied functions, just like in functional languages. It returns a new function object where some of the arguments of the original function have been bound to some values. In this case x is bound to the second argument of is_divisible_by.
  16. The lambda function automatically captures variables from the enclosing scope into a function object that is created implicitly.
  17. To tell the compiler what return type to use, specify it with the -> syntax. If the compiler fail to deduce the return type.
  18. Every time you start a new C++ project, and you go about setting up your shape hierarchy, you run the risk of falling into this trap.
  19. your rectangles are never drawn!
  20. the override keyword diagnose this at compile time
  21. let’s say shape derives from entity, and you don’t want shapes to be able to implement their own move function.
  22. replaces std::auto_ptr<>. takes great advantage of move semantics. unique because there’s always exactly one pointer pointing to the held object.
  23. can be used as a scoped_ptr<>, where you want to allocate an object on the heap with scope-lifetime.
  24. can be used to return heap allocated objects with no ownership issue.
  25. shared ownership, where multiple pointers point to the same object, each of them keeping it alive. Only when the last pointer/reference goes away, is the object deleted.
  26. contrived example. the asynchronous operation keeps the socket object alive.