Home > On-Demand Archives > Talks >

A decade of Modern C++; from 11 to 20

Niall Cooling - Watch Now - EOC 2021 - Duration: 46:31

In 2011 ISO published a new version of C++. The C++11 standard was a major change to the language, not only from syntactical perspective but, more significantly, requiring a new approach to designing and developing with C++.

Over the last decade, we have seen three further revisions of the standard (C++14/17/20), culminating in the release of C++20 in December of last year.

However, many embedded engineers are still wary of C++ and live with the misconception that it is unsuitable for embedded development.

This talk looks at the evolution of C++ and where an embedded engineer may realise significant safety and performance benefits by adopting modern C++.

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 | 3 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 ;)

OUR SPONSORS

OUR PARTNERS