SlideServe
Menu
Préférences
© SlideServe · v2026

Rock Hard: C++ Evolving

ophrah avatar
31 diapositives · 499 Views · Jul 21, 2014

Rock Hard: C++ Evolving. Boris Jabes blogs.msdn.com/vcblog (@ visualc ). C++0x to become C++11. FDIS Submitted to ISO. Power & Performance on any Platform. “ Higher-level style of programming more natural than before and as efficient as ever.”

Rock Hard: C++ Evolving - slide 1
01 / 31Rock Hard: C++ Evolving
1 / 17

Télécharger la présentation

Rock Hard: C++ Evolving
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Rock Hard: C++ Evolving Boris Jabes blogs.msdn.com/vcblog(@visualc)

  2. C++0x to become C++11 FDIS Submitted to ISO

  3. Power & Performance on any Platform “Higher-level style of programming more natural than before and as efficient as ever.” “If you timidly approach C++ as just a better C or as an object-oriented language, you are going to miss the point.”

  4. Programming with Values Value = No State || Deep Copy Requires a little bit of forethought

  5. Silly? Bar Foo(Bar x) { // check for null if (x == null) // throw exception ... } • int Foo(int x) • { • // check for null • if (x == null) • // throw exception • ... • }

  6. POD • struct fighter { • string name; • int health; • }; // just works! • int main() { • fighter bart= { “bart”, 25 }; • fighter lisa = bart; // works just like int! • return 0; • }

  7. Dynamic Data • struct fighter { • T* data; • string name; • int health; • fighter(string s, int h) : • name(s), health(h), data(new T[1000]) {} • }; • int main() { • fighter bart = { “bart”, 25 }; • fighter lisa = bart; // shallow copy • return 0; • }

  8. Dynamic Data • struct fighter { • T* data; • string name; • int health; • fighter(string s, int h) : • name(s), health(h), data(new T[1000]) {} • fighter(const fighter& o) : • name(o.name), health(o.health), data(new T[1000]) { • std::copy(o.data,o.data+1000,data); • } • }; • int main() { • fighter bart = { “bart”, 25 }; • fighter kirk(get_fighter()); // this works • fighter lisa = bart; // this doesn’t • return 0; • }

  9. Dynamic Data • structfighter { • T* data; • string name; • int health; • fighter(string s, int h) : • name(s), health(h), data(new T[HUGE]) {} • fighter(const fighter& o) : • name(o.name), health(o.health), data(new T[HUGE]) { • std::copy(o.data,o.data+HUGE,data); • } • void swap(fighter& left, fighter& right) { • std::swap(left.name,right.name); • std::swap(left.health,right.health); • std::swap(left.data,right.data); // swap head pointer • } • fighter& operator=(fighter o) { • swap(*this,o); • return *this; • } • };

  10. Expensive Copy • structfighter { • T* data; • string name; • int health; • fighter(string s, int h) : • name(s), health(h), data(new T[HUGE]) {} • fighter(const fighter& o) : • name(o.name), health(o.health), data(new T[HUGE]) { • std::copy(o.data,o.data+HUGE,data); • } • friend void swap(fighter& left, fighter& right) { • std::swap(left.name,right.name); • std::swap(left.health,right.health); • std::swap(left.data,right.data); // swap head pointer • } • fighter& operator=(fighter o) { • swap(*this,o); • return *this; • } • fighter(fighter&& o) : data(nullptr) { • swap(*this,o); • } • };

  11. Destructors + RAII = The Best of C++ Determinism for Resources Cache-Locality Seamless with Exceptions Zero Burden on API Consumer

  12. Higher-Order Programming Multi-Paradigm Generic Control And Yet… Efficient

  13. Control in Context Lambdas

  14. C# • List<Action> actions = new List<Action>(); • for (int counter = 0; counter < 10; counter++) • { • actions.Add(() => Console.WriteLine(counter)); • } • foreach(Action action in actions) • { • action(); • }

  15. C# • List<Action> actions = new List<Action>(); • for (int counter = 0; counter < 10; counter++){intcopy = counter;actions.Add(() => Console.WriteLine(copy));}foreach(Action action in actions){ action();}

  16. C++ • vector<function<void()> actions; • for (int counter = 0; counter < 10; counter++) • { • actions.push_back([&] { • cout << counter << endl; • }); • } • for(int i=0; i<actions.size(); ++i) • { • actions[i](); • }

  17. C++ • vector<function<void()> actions; • for (int counter = 0; counter < 10; counter++) • { • actions.push_back([=] { • cout << counter << endl; • }); • } • for(int i=0; i<actions.size(); ++i) • { • actions[i](); • }

  18. C++11 Coming Soon to a Compiler Near You Modern C++ != “C with Classes” C++11 = Expressive Without Sacrifice C++11 is Concurrent Go Forth & Be Merry

  19. Stay up to date with MSDN Belux • Register for our newsletters and stay up to date:http://www.msdn-newsletters.be • Technical updates • Event announcements and registration • Top downloads • Follow our bloghttp://blogs.msdn.com/belux • Join us on Facebookhttp://www.facebook.com/msdnbehttp://www.facebook.com/msdnbelux • LinkedIn: http://linkd.in/msdnbelux/ • Twitter: @msdnbelux DownloadMSDN/TechNet Desktop Gadgethttp://bit.ly/msdntngadget

  20. TechDays 2011 On-Demand • Watchthis session on-demand via Channel9http://channel9.msdn.com/belux • Download to your favorite MP3 or video player • Get access to slides and recommended resources by the speakers

  21. THANK YOU