Youtube - CppCon 2014 Herb Sutter Back to the Basics! Essentials of Modern C++ Style

https://www.youtube.com/watch?v=xnqTKD8uD64
 02:38

Pasted image 20231217233156.png
NĂșmero de desenvolvedores que estĂŁo diretamente envolvidos em cada standard library em C++. CLang eram apenas duas atĂ© pouco tempo!!!

Gnu GCC (libstdc++) - em 20 anos, cerca de 30 desenvolvedores
CLang (libc++) - até dois meses antecedentes à época da publicação da palestra eram apenas 2 desenvolvedores diretamente envolvidos (atualmente 5 a 7 ativos)
Boost - cerca de 300, sem nĂșmero exato.

Loop, range for

 09:08

Pasted image 20231217234647.png

 10:33

Pasted image 20231218060338.png

Prefer range for

Why you do this:
for (auto i = begin(c) ; i != end(c)) ; i++ {...use(*c*) ....}
when you can do this
for (auto& e : c) { ... use(e) ... }
and soon this
for (e : c ) { ... use(e) ... }

Smart Pointers

 12:14

Pasted image 20231218063351.png

 13:33

Pasted image 20231218063851.png

 14:44

Pasted image 20231218064246.png

 16:52

Pasted image 20231218064720.png

 17:05

Pasted image 20231218064851.png

 17:54

Pasted image 20231218065001.png

 17:56

Pasted image 20231218065021.png

 18:45

Pasted image 20231218065135.png

Pasted image 20231218065234.png

How to we pass smart pointers?

 19:06

Pasted image 20231218065924.png

 22:26

Pasted image 20231218070649.png

 22:44

Pasted image 20231218071043.png

 23:50

Pasted image 20231218071415.png

 24:37

Pasted image 20231218071511.png

 25:35

Pasted image 20231218081753.png

 27:30

Pasted image 20231218124719.png

 27:44

Pasted image 20231218132155.png

LetÂŽs talk about auto

 30:04

Pasted image 20231218132657.png

Tip

vocĂȘ pode usar auto e ainda sim explicitar o tipo

Pasted image 20231218133653.png

 32:59

Pasted image 20231218134019.png

Why deduce?

 34:19

Pasted image 20231218134344.png

 35:19

Pasted image 20231218134622.png

 37:26

Pasted image 20231218134728.png

 38:21

Pasted image 20231218134847.png

 38:37

Pasted image 20231218134919.png

 38:57

Pasted image 20231218134929.png

 39:37

Pasted image 20231221062837.png

 41:18

Pasted image 20231221062940.png

 41:48

Pasted image 20231221063245.png

Pasted image 20231221063307.png

 45:09

Pasted image 20231221063546.png

 46:54

Pasted image 20231221063638.png

 47:50

Pasted image 20231221063744.png
Pasted image 20231221063752.png

 49:32

Pasted image 20231221093523.png

 50:22

Pasted image 20231221093621.png

 50:45

Pasted image 20231221121158.png

 51:17

Pasted image 20231221121235.png

 53:15

Pasted image 20231221121600.png
Pasted image 20231221121704.png

Observation “New features get overused.” — B. Stroustrup or “It’s about the Ivalues, after alll” —S. Meyers
Just as exception safety isn’t all about writing try and catch, using move semantics isn’t all about writing move and &&

 54:48

Pasted image 20231221121748.png
Up Front: Acknowledgments & Hat Tips » The following is the result of recent discussions with many people, including but not limited to the following: » Gabriel Dos Reis » Matthew Fiovarante (&& param = move from) » Howard Hinnant (distinguish copy ctor/op= costs vs. move) » StephanT. Lavavej (low cost of value return even in C++98) » Scott Meyers (reduce #objects, be aware of costs ) » Eric Niebler » Sean Parent » Bjarne Stroustrup (practicality, judgment, design sense) » VC+ MVP discussion list » & many more

 55:22

cpp98_reasonable_default_advice.png

 57:32

Pasted image 20231221125616.png

 58:59

Pasted image 20231221125738.png

 59:05

Pasted image 20231221125753.png

 01:01:38

Pasted image 20231221130035.png

 01:03:15

Pasted image 20231221131434.png

 01:03:54

Pasted image 20231221131513.png

 01:05:23

Pasted image 20231221131646.png

setName ?

 01:06:47

Pasted image 20231221131843.png
Pasted image 20231221131928.png

 01:07:50

Pasted image 20231221131944.png

 01:09:33

Pasted image 20231221132146.png

Warning

A segunda função que usa rvalue pode ser noexcept, pois não existe alocação de memória

 01:11:58

Pasted image 20231221132625.png

setName otimizado,

Warning

#performance A função não pode ser virtual e tem que estar no header, use com cautela somente em situaçÔes que a performance seja extremamente necessåria.

Perfect Forwarding Idiom

 01:15:21

Pasted image 20231221134635.png

 01:19:10

Pasted image 20231221135400.png

Pasted image 20231221135659.png

Pasted image 20231221135724.png

Pasted image 20231221135829.png

 01:23:34

Pasted image 20231221135858.png

 01:25:04

Pasted image 20231221140147.png

 01:25:50

Pasted image 20231221140232.png
Pasted image 20231221140240.png

Pass by value for constructors

 01:25:49

Pasted image 20231221140259.png

Pass by value for constructors

#best-practices #efficiency #performance ItÂŽs always a good idea pass by value for constructors

Default

 01:26:57

Pasted image 20231221140942.png

Pasted image 20231221141003.png

forwarding reference

 01:27:12

Pasted image 20231221141204.png

 01:29:18

Pasted image 20231221141356.png

 01:31:10

Pasted image 20231221141555.png

 01:31:24

Pasted image 20231221141628.png

Pasted image 20231221141820.png

 01:33:17

Pasted image 20231221141843.png