CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++”
Why Hacker News recommends it
Praised as the best talk of CppCon 2017 and the key introduction to metaclasses and generative C++.
What it is
At CppCon 2017 Herb Sutter presents his work on evolving C++ through compile-time code generation, including metaclasses and reflection. The aim is to make the language both more powerful and simpler by letting programmers express intent directly.
Recommended by 2 HN commenters across 2 different months, 2017 to 2020.
What Hacker News said
Strong rec slavik81 · 2017-10 · on “C++17 Is Here: Interview with Herb Sutter”
Herb Sutter's talk about it is by far the best talk I've seen from from CppCon17. "Meta: Thoughts on generative C++" - [this video]
Strong rec xaedes · 2018-01 · on “Outperforming LAPACK with C++ metaprogramming”
The talk about the reflection proposal was amazing. Meta classes are also very cool. We can only hope it comes fast. [this video]
Cites tylerhou · 2020-12 · on “Is the preprocessor still needed in C++? (2017)”
A few years ago Herb Sutter proposed Python-like metaclasses in C++ through compile-time code generation. Not sure if anything has been proposed for general use. [this video]
Cites tylerhou · 2020-12 · on “Is the preprocessor still needed in C++? (2017)”
To a degree, but templates and constexpr don't support a bunch of features like compile-time field enumeration and introspection + code generation. For example, let's say I have a bunch of structs: struct GeoCoordinate { int lat, long; }; struct GeoArea { std::vector<GeoCoordinate> perimeter; }; struct Place { std::string name; std::string contact_number; GeoArea area; }; Now I need to serialize these structs into a format to be sent over the wire. Currently, I have a few choices: 1. Use an off-the-shelf library like protobuf (disclaimer: I work for Google). Then I have to convert my code to a protobuf definition and rely on its code generator to perform [de]serialization. I also have to hop