Compiler-friendly metaprogramming

Day 2 /  / Track 1  /  RU / Hardcore. Really hard and demanding talk, you'll understand only if you're an experienced engineer.

Every developer plunging into the C++ world knows that templates are Turing complete, substitution failure is not an error, and in compile-time you can do amazing, sometimes even useful things. On the other side, an experienced C++ developer understands that "you can" does not mean "you should" and that there is a price for abusing metaprogramming. Compilation time is one of the most crucial bottlenecks, so we'll discuss which operations/techniques are the most expensive for the compiler and how we can avoid them.

We'll cover several issues, including:

  • why SFINAE is the last thing you should use;
  • why std::conditional_t is defined inefficiently;
  • what's the difference between tuple implementations in Microsoft STL and libc++;
  • when you should use std::{conjunction,disjunction} and when — fold expressions;
  • why you shoudln't use std::void_t;
  • how the concepts appearing in C++20 can help you.