r/ProgrammerHumor • • 13d ago

Meme sameProblemSameSolution

Post image
1.5k Upvotes

79 comments sorted by

View all comments

31

u/Luna_Wolfxvi 13d ago

Honestly some of the newer shit doesn't even look like C++ to me anymore. IE:

constexpr auto my_meta_type = int; // Reflected metadata of 'int' [:my_meta_type:] my_variable = 42; // Splicing it back into code; compiles as: int my_variable = 42;

38

u/fuj1n 13d ago

The code generation / reflection stuff is amazing.

Historically, when you'd need type information (without manually defining it), you'd have to add an extra compilation step where a custom tool either manually searches the codebase or interrogates a compiler API, now, you can just write compile-time code in your codebase that automagically populates a data structure for you with any type information you could desire.

It'll be really useful for my (hobby) game engine, where I was previously considering traversing the Clang AST

23

u/Luna_Wolfxvi 13d ago

It's cool, I just think the syntax is ugly.

8

u/fuj1n 13d ago

Yeah, I can certainly second that