logoalt Hacker News

kjksf06/15/20254 repliesview on HN

I can honestly say that I couldn't write that thing in 100 years.

I can't even read it.

That's the fundamental problem with C++: I've understood pretty much all Go code I ever looked at.

The code like the above is so obtuse that 0.001% of C++ programmers is capable of writing it and 0.01% is capable of understanding it.

Sure, I can treat it as magic but I would rather not.


Replies

moonshadow56506/16/2025

It's not that complex if you remove all the stuff you don't use: https://godbolt.org/z/rM9ejojv4 .

Main things you would need to understand is specialization (think like pattern matching but compile time) and pack expansion (three dots).

mandarax806/15/2025

Yeah it's a shame that to go from your idea to something that's 'general' (ie just some arbitrary arguments) you need to write this arcane garbage.

spacechild106/15/2025

Do you understand how your compiler works? Shouldn't you be writing assembly instead? You can't understand all internals and that's perfectly fine.

Why do you even care how std::function is implemented? (Unless you are working in very performance critical or otherwise restricted environments.)

show 2 replies