Author: Sy Brand
-
Guaranteed Copy Elision Does Not Elide Copies
This post is also available at the Microsoft Visual C++ Team Blog C++17 merged in a paper called Guaranteed copy elision through simplified value categories. The changes mandate that no copies or moves take place in some situations where they were pre…
-
Spaceship Operator
You write a class. It has a bunch of member data. At some point, you realise that you need to be able to compare objects of this type. You sigh and resign yourself to writing six operator overloads for every type of comparison you need to make. Afterwa…
-
Super Simple Named Boolean Parameters
Quite often we come across interfaces with multiple boolean parameters, like this: cake make_cake (bool with_dairy, bool chocolate_sauce, bool poison); A call to this function might look like: auto c = make_cake(true, true, false); Unfortunately,…
-
Function Template Partial Ordering: Worked Examples
C++ function overloading rules are complex. C++ template rules are complex. Put the two together, and you unfortunately do not get something simple; you get a hideous monster of standardese which requires great patience and knowledge to overcome. Howev…
-
std::accumulate vs. std::reduce
std::accumulate has been a part of the standard library since C++98. It provides a way to fold a binary operation (such as addition) over an iterator range, resulting in a single value. std::reduce was added in C++17 and looks remarkably similar. This …
-
Custom Alias Analysis in LLVM
At Codeplay I currently work on a compiler backend for an embedded accelerator. The backend is the part of the compiler which takes some representation of the source code and translates it to machine code. In my case I’m working with LLVM, so this repr…
-
No more pointers
This was an April Fools post. One of the major changes at the most recent C++ standards meeting in Jacksonville was the decision to deprecate raw pointers in C++20, moving to remove them completely in C++23. This came as a surprise to many, with a lot…
-
emBO++ 2018 Trip Report
emBO++ is a conference focused on C++ on embedded systems in Bochum, Germany. This was it’s second year of operation, but the first that I’ve been along to. It was a great conference, so I’m writing a short report to hopefully convince more of you to a…
-
Do compilers take inline as a hint?
If you’ve spent any time in C or C++ communities online, you’ve probably seen someone say this: inline used to be a hint for compilers to inline the definition, but no compilers actually take that into account any more. You shouldn’t believe ever…
-
Passing overload sets to functions
Passing functions to functions is becoming increasingly prevalent in C++. With common advice being to prefer algorithms to loops, new library features like std::visit, lambdas being incrementally beefed up12 and C++ function programming talks consisten…