Home > On-Demand Archives > Q&A Sessions >

Live Q&A - A decade of Modern C++; from 11 to 20

Niall Cooling - Watch Now - EOC 2021 - Duration: 20:12

Live Q&A with Niall Cooling for the talk titled A decade of Modern C++; from 11 to 20
M↓ MARKDOWN HELP
italicssurround text with
*asterisks*
boldsurround text with
**two asterisks**
hyperlink
[hyperlink](https://example.com)
or just a bare URL
code
surround text with
`backticks`
strikethroughsurround text with
~~two tilde characters~~
quote
prefix with
>

DaveN
Score: 0 | 3 years ago | 1 reply

Regarding copy elision and return value optimization: I was shocked this was not already part of the standard as I thought! I've relied on this in some code from 25 years ago (!) to efficiently return objects from functions (without copying via copy ctor). I just ran some tests to be sure: believe it or not RVO copy elision was performed by the 1995 Borland 5.0 16-bit C++ compiler (which I'm still occasionally using to support an old embedded x86 product), as well as GCC 5.4 from 2014. Thanks again, Best Regards, Dave

NiallSpeaker
Score: 0 | 3 years ago | no reply

Hi Dave,
Copy-elision has been a fairly standard compiler optimization for many years now (though I had no idea it would work on the Boland compiler). I certainly worked on GCC back in the 2.x days. However, it was very dependent on the toolchain, optimisation settings and the code you wrote. For example to get copy-elision to work on many compilers you had to write a copy-constructor for it then to be eluded. If you didn't have a copy-ctor then the compiler would default back to shallow copies. The major benefit in C++17 is making it mandatory.
Regards,
Niall.

Harri
Score: 0 | 4 years ago | 1 reply

Great talk, thank you! Got good reminders of what's possible with copy elision and std::optional. Will have to simplify my error handling in the future :)

NiallSpeaker
Score: 0 | 3 years ago | no reply

Hi Harri,
I find it more intuitive to use, especially with tuples/optional especially for error management.
Thanks,
Niall

DaveN
Score: 0 | 4 years ago | 1 reply

Hi Niall - Thanks for a great talk! I tried to have a look at your blog but each entry ends with [...] but no way to see the complete entry (I expected the ellipsis to be a link but it was not)?
https://blog.feabhas.com/category/programming/
Thanks, Best Regards, Dave

NiallSpeaker
Score: 0 | 3 years ago | 1 reply

Hi Dave,

The [?] is a wordpress marker for a break. If you click on the blog title you?ll see the full blog

Niall

DaveN
Score: 0 | 3 years ago | no reply

Thanks Nial, I eventually figured it out. Really unfortunate that the WordPress template does not use standard link formatting to make it obvious and/or make the ellipsis a link! Thanks again for a great talk,
Best Regards, Dave

Ion
Score: 0 | 4 years ago | 1 reply

Hi Niall - Thanks for great talk. Tuples and optional do they use dynamic allocation in their implementation ?

NiallSpeaker
Score: 0 | 3 years ago | no reply

H Ion,
No they don?t. Tuples are basically an anonymous struct so same memory model. optionals are a union of the type and a bool.
Is a simple as that.
Niall.

mgaron
Score: 0 | 4 years ago | 1 reply

Found I was well leveraging lots of features of C++11, but not so much for c++14/17. Still room for improvement. Definitely some construct I will be investigating further after this lecture.
Well done and thanks for sharing this knowledge!

NiallSpeaker
Score: 0 | 4 years ago | 1 reply

Don't underestimate the copy-elision & structure-binding from C++17, it's surprising how much it changes your code, especially regarding readability and maintenance.
Alway room for improvement, I'd like to see better support for compile-time lifetime management as with Rust.

mgaron
Score: 0 | 4 years ago | no reply

That's the two which caught my attention the most. I will also definitely add std::optional template, and nodiscard attribute to my arsenal. About room for improvement, I was speaking about my usage of the C++ features, not the standards themselves. Hope it didn't create confusion ;)

09:45:24	 From  Raul Pando : Hi Niall, I like how lambdas help reducing the scope for anonymous functions. However, I found it tricky to trace code while debugging content within them. Do you have any recommendations?
09:46:58	 From  Tom.Davies : I’ve tried to look into c++ a couple of times but I’ve had trouble finding learning resources that limit the focus to embedded and most quickly start coving areas of the language that aren’t appropriate for the embedded space. Can you point to any resources for learning c++, from the ground up, with an embedded focus?
09:47:45	 From  enrico : https://www.springer.com/gp/book/9783662567173
09:48:29	 From  Tom.Davies : Thank you Enrico
09:49:10	 From  Pulkit Gupta : Thanks Tom and Enrico. I also had the same question
09:49:26	 From  busa2191 : Where or what is the best reference to C++20 Embedded.
09:51:42	 From  Pulkit Gupta : I would like to know about a book or information on what features of Modern C++ to avoid in real time systems running on VxWorks for example considering someone moving from C++98 to C++11 or newer
09:51:50	 From  Raul Pando : How much of the Standard Template Library (STL) is available when dynamic memory allocation for containers is out of the question?
09:53:31	 From  jvillasante : Have you played with coroutines on an embedded context? Are stackless coroutines ready for embedded?
09:57:14	 From  Dave Nadler : Thanks Niall - Super presentation, really educational.
10:00:25	 From  Radu Pralea : https://www.amazon.com/Hands-Embedded-Programming-versatile-solutions/dp/1788629302
?
10:01:03	 From  Pulkit Gupta : thanks Radu
10:01:06	 From  Tom.Davies : Thank you Niall, will check out the course list
10:01:30	 From  Raul Pando : Thanks Niall
10:01:32	 From  Radu Pralea : No, I think this is the one Niall said not to go to :)
10:01:39	 From  Vim : Thank you
10:01:47	 From  Tony Arkles : Thanks! The talk and the Q&A was amazing!!!

OUR SPONSORS

OUR PARTNERS