Back To Basics: The Special Member Functions - Klaus Iglberger - CppCon 2021

  Рет қаралды 20,464

CppCon

CppCon

Күн бұрын

cppcon.org/
github.com/CppCon/CppCon2021
---
The six special member functions. Do you know them all? Do you know when the compiler generates them for you and what they are doing? And most importantly, do you know when they don’t give you what you expect? In this talk I will explain the six special members in detail. We will take a look at the exact circumstances when a compiler would generate these functions, what they are doing by default and when we should deal with them manually. Also, among many other guidelines I’ll explain why we should strive for the Rule of 0, why the Rule of 5 is sometimes unavoidable, and why the Rule of 3 is not obsolete.
---
Klaus Iglberger
Klaus Iglberger is a freelancing C++ trainer and consultant. He has finished his PhD in computer science in 2010 and since then is focused on large-scale C++ software design. He shares his experience in popular advanced C++ courses around the world (mainly in Germany, but also the EU and US). Additionally, he is the initiator and lead designer of the Blaze C++ math library (bitbucket.org/blaze-lib/blaze...) and one of the organizers of the Munich C++ user group (www.meetup.com/MUCplusplus/).
---
Videos Streamed & Edited by Digital Medium: online.digital-medium.co.uk
*--*

Пікірлер: 25
@dragonwarrior3356
@dragonwarrior3356 2 жыл бұрын
I feel Klaus is the only person who bring contents which every C++ programmer needs. Great presenter !!
@thestarinthesky_
@thestarinthesky_ Ай бұрын
Klaus is the best❤ thanks for sharing videos and classifying “back to basic” on the playlist! It has helped beginners like me a lot ❤appreciate it 🌸
@9uiop
@9uiop 2 жыл бұрын
Great talk! Whether it's a B2B or more advanced topic, Klaus has a great way explaining things.
@CppCon
@CppCon 2 жыл бұрын
Glad you enjoyed it!
@niteshkumarsukumaran
@niteshkumarsukumaran 2 жыл бұрын
Love watching Klaus explaining things to the point! Thanks for doing this 👍
@CppCon
@CppCon 2 жыл бұрын
Glad you enjoyed it!
@kacperkrol4394
@kacperkrol4394 2 жыл бұрын
To be honest, imho Klaus You are the best lecturer on cppcon. Great job!
@dkutagulla
@dkutagulla 2 жыл бұрын
Absolutely Amazing! You are my c++ teacher
@germancaino
@germancaino 2 жыл бұрын
Excellent talk, as always from Klaus.
@CppCon
@CppCon 2 жыл бұрын
Thanks for listening
@kuijaye
@kuijaye 5 ай бұрын
Great talk. Idk how i can thank you cppcon and esp Klaus.
@yuvalboker557
@yuvalboker557 Жыл бұрын
You are an amazing teacher!
@SuperMopga
@SuperMopga 2 жыл бұрын
Vielen Dank, Klaus!
@SamWhitlock
@SamWhitlock 2 жыл бұрын
43:03 the example I always go to about where self assignment could occur is in a buggy implementation of quicksort. If the algorithm to swap values around the pivot is not implemented correctly and one has an odd number of elements, the buggy algorithm may decide to swap the last item (where both the high and low cursors point to the same value); after all, any value should not be less than itself if std::less is being used. "just don't get into a situation where self-assignment is possible" is nice in theory, but in real codebases (especially with template code) it happens, and it's preferable to limp along with misuse of the assignment operator than it is to blow up in a strange way.
@samolisov
@samolisov 2 жыл бұрын
33:33 If the copy assignment operator is implemented as it is written on the slide, this is a good point where pass by value can simplify the code a little bit: Widget(Widget other). But passing by reference brings some flexibility and we can check some conditions as it was done at 33:55.
@maneshipocrates2264
@maneshipocrates2264 Жыл бұрын
Greta talk... but is it okay to declare your copy constructor as Widget(const Widget& someVar)?
@johnhsu5459
@johnhsu5459 Жыл бұрын
=delete Does not delist the function but to disable it. Only shit I hope committee try another keyword instead, this answers a bunch of my problems..
@hemangandhi4596
@hemangandhi4596 2 жыл бұрын
I wish this went over the ordering of the initialization and deletion because I keep getting clang-tidy warnings about initialization order and it's quite confusing.
@darranrowe174
@darranrowe174 2 жыл бұрын
Without further information then there has to be a certain amount of guessing going on. The most common initialisation order issue is where members are not initialised in the same order as they are declared. struct s { s() : b(0), a(1) {} int a; int b; }; The reason why this is an issue is that the compiler will initialise members in the order that they are declared, not the order that the constructor initialises them in the initialiser list. So as an example, what do you think would happen if the constructor was: s() : b(0), a(b) {} ? If you guess that a will contain an undefined value then congratulations.
@meowsqueak
@meowsqueak Жыл бұрын
If you write a base class, and therefore (as per best practices) declare a _virtual_ destructor even if it doesn't actually do anything, does that mean you then have to explicitly provide (or declare =default) the copy constructors as well? I've seen cases where a new abstract base class with a virtual destructor is defined, just for this purpose, and then the other 5 special member functions are =default - but that seems onerous to do every single time one wants to write a potential base class.
@germancaino
@germancaino Жыл бұрын
I was going to ask the same thing.
@victorcruceru3246
@victorcruceru3246 2 жыл бұрын
Lots of slides where the author has written "delete resource" instead of "delete pr".
@vishalbhadre178
@vishalbhadre178 Жыл бұрын
#56.00 Assignment operation needs to return *this because it is required in cascaded assignment
@__hannibaal__
@__hannibaal__ Жыл бұрын
What happen if put destructor in private: and call them by member function as pointer; Like private : ~Widget(){//…….//} Public: ….. ….. Void deleted(){ this->~Widget();} } Than you can call it or not call it … Is there other trick about it , what happen if not deleted or not call it.
@flocela
@flocela Жыл бұрын
Finally, the truth about =delete; The function exists but is disabled. Unfortunate naming.
Back to Basics: Classic STL - Bob Steagall - CppCon 2021
1:01:31
I Need Your Help..
00:33
Stokes Twins
Рет қаралды 172 МЛН
The Worlds Most Powerfull Batteries !
00:48
Woody & Kleiny
Рет қаралды 27 МЛН
IS THIS REAL FOOD OR NOT?🤔 PIKACHU AND SONIC CONFUSE THE CAT! 😺🍫
00:41
Каха инструкция по шашлыку
01:00
К-Media
Рет қаралды 7 МЛН
CppCon 2019: Jason Turner “The Best Parts of C++"
58:36
CppCon
Рет қаралды 89 М.
Back to Basics: Lambdas - Nicolai Josuttis - CppCon 2021
1:05:21
are "smart pointers" actually smart?
9:44
Low Level Learning
Рет қаралды 69 М.
Задача APPLE сделать iPHONE НЕРЕМОНТОПРИГОДНЫМ
0:57
ПРОБЛЕМА МЕХАНИЧЕСКИХ КЛАВИАТУР!🤬
0:59
Корнеич
Рет қаралды 3,8 МЛН
Bluetooth Desert Eagle
0:27
ts blur
Рет қаралды 3,8 МЛН
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 11 МЛН
WWDC 2024 - June 10 | Apple
1:43:37
Apple
Рет қаралды 9 МЛН