BohdanQQ

C++ Notes

Here, I keep a note list of C++ features that I find interesting or useful. Beware that I've written those notes down on the fly as I understood them and my understanding might be incomplete or incorrect!

Source:

Atrtributes - C++23

A list (to have them in one place), source/inspiration:

noreturn, deprecated("description"), fallthrough, (un)likely, maybe_unused (be careful)

carries_dependency

nodiscard

no_unique_address

assume(predicate expr)

Stream manipulators

std::boolalpha - to print true/false instead of 1/0

Templates / metaprogramming

C++20 Idioms for parameter packs by David Mazières

The initial parts are particularly useful if you'd like to refresh on the parameter pack syntax and folds.

Multilambdas are (I think) also explained in Jason Turner's C++ weekly series, as well as fold expressions.

Compilers

C++ insights:

From their about page:

C++ Insights is a clang-based tool which does a source to source transformation. Its goal is to make things visible, which normally and intentionally happen behind the scenes. It's about the magic the compiler does for us to make things work. Or looking through the classes of a compiler.

C++ 23 features

Explicit Object Parameters

class C {
  void f(this C& self) {}

  // deducing this
  template <class C>
  auto&& g(this C&& self) {}
}

if consteval

Quick List - language features

Monadic operations on std::optional

Ranges updates

to - ranges to containers
Folds

Views

std::expected

Quick list - library features

Misc

Last update

3rd June 2024