Did you know `4[array]` is valid C++? This talk uncovers the language's most obscure and horrifying features you were never taught.
#1about 1 minute
Understanding commutative array indexing in C++
The built-in array index operator is commutative because it is defined in terms of pointer arithmetic, allowing for unusual but valid syntax like `index[array]`.
#2about 1 minute
Using the unary plus operator for type promotion
The unary plus operator can be used to trigger integral promotions, convert enums to their underlying type, and decay arrays or lambdas to function pointers.
#3about 1 minute
Leveraging the comma operator with fold expressions
The comma operator evaluates expressions from left to right, making it a powerful tool for applying an operation to each element of a parameter pack using a fold expression.
#4about 4 minutes
Exploring quirks in C++ control flow syntax
The `else if` construct is just an `else` followed by an `if` statement, and `switch` statements allow for unusual structures like placing the default case first or implementing Duff's device.
#5about 2 minutes
Handling floating-point exceptions and NaN values
C++ provides functions to test for floating-point exceptions like division by zero and to create specific "Not a Number" (NaN) values, which can be used for techniques like NaN boxing.
#6about 1 minute
The flexibility of declaration specifier order
Declaration specifiers like `const`, `unsigned`, `static`, and `inline` can appear in any order before the type name, allowing for unconventional but valid declarations.
#7about 1 minute
Decoding complex C++ declarators
The declarator part of a declaration, which includes the name and operators like `*` or `()`, can be combined to declare pointers, variables, and functions in a single statement.
#8about 1 minute
Using function try blocks in constructors
Function try blocks are essential for catching exceptions thrown from a constructor's member initializer list, as a regular try-catch block cannot surround it.
#9about 1 minute
The overlooked `std::valarray` for vector math
`std::valarray` is a standard library container designed for efficient, element-wise numerical operations and can be a good alternative to custom vector types for mathematical computations.
#10about 1 minute
Finding the most derived object with `dynamic_cast`
Using `dynamic_cast<void*>` on a pointer to a base class returns the address of the most derived object in the hierarchy, which is useful for type-erasure implementations.
#11about 2 minutes
Leveraging the common initial sequence in unions
The common initial sequence rule allows reading non-active members of a union if they share the same initial layout, enabling space optimization by overlaying common fields.
#12about 2 minutes
Undefined behavior in signed integer arithmetic
Signed integer overflow is undefined behavior in C++, which can occur not only in addition and multiplication but also in specific division cases like `INT_MIN / -1`.
#13about 3 minutes
The `sizeof` operator precedence puzzle
The `sizeof` operator has lower precedence than the array index operator, leading to surprising results where `sizeof +a[i]` is parsed as `sizeof(+(a[i]))`.
Related jobs
Jobs that call for the skills explored in this talk.
Matching moments
07:50 MIN
Using modern language features for safer code
C++ in constrained environments
05:24 MIN
Debunking common myths about C++ in constrained systems
C++ in constrained environments
06:50 MIN
C++ availability, ecosystem, and backwards compatibility
101 brilliant things of C++
07:24 MIN
Q&A on local error handling and C++23 features
C++ in constrained environments
08:47 MIN
Q&A on language design, Rust, and the future of C++
The Design and Evolution of C++
04:40 MIN
Core strategies for achieving high performance
The Design and Evolution of C++
07:52 MIN
Modern C++ evolution and the burden of backward compatibility
Eternal Sunshine of the Spotless Programming Language
07:25 MIN
Core design principles and the language evolution trilemma
Dev Digest 138 - Are you secure about this?Hello there! This is the 2nd "out of the can" edition of 3 as I am on vacation in Greece eating lovely things on the beach. So, fewer news, but lots of great resources. Many around the topic of security. Enjoy! News and ArticlesGoogle Pixel phones t...
Chris Heilmann
All the videos of Halfstack London 2024!Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
Dev Digest 128 - Do not Google MonopolyHello fellow developer, who watches the watchmen and what is a monopoly? Well, let's find out and learn a few things about new web features and accessibility along the way.News and ArticlesIt is official that Google has monopolised search through ill...
Chris Heilmann
Dev Digest 122 - Cracks in the polyfillHello fellow developer, join us to learn about removing malicious code, what the web is up to and why there are some cool new careers in AI.News and ArticlesFirst things first: if you use Polyfill.io delete it immediately from your server! The - by n...
From learning to earning
Jobs that call for the skills explored in this talk.