logoalt Hacker News

sagacityyesterday at 8:43 AM6 repliesview on HN

Oof, that first example (the idiomatic C++26 way) looks so foreign if you're mostly used to C++11.


Replies

delegateyesterday at 2:31 PM

I was very curious to see what C++ 26 brings to the table, since I haven't used C++ in a while.

When I saw the 'no boilerplate' example, the very first thought that came to my mind:

This is the ugliest, most cryptic and confusing piece of code I've ever seen. Calling this 'no boilerplate' is an insult to the word 'boilerplate'.

Yeah, I can parse it for a minute or two and I mostly get it.

But if given the choice, I'd choose the C-macro implementation (which is 30+ years old) over this, every time. Or the good old switch case where I understand what's going on.

I understand that reflection is a powerful capability for C++, but the template-meta-cryptic-insanity is just too much to invite me back to this version of the language.

show 3 replies
randusernameyesterday at 12:41 PM

I was a fool to assume that the same forces shaping the ugliness of C++ syntax would not also be at work in C++ 26.

show 1 reply
mort96yesterday at 8:42 PM

I wish I understood the reason for the `std::define_static_array`... Why can't `std::meta::enumerators_of` just return something that can be iterated through????

show 1 reply
spacechild1yesterday at 7:34 PM

I find it quite readable. I can understand what it does even though I haven't written reflection code yet myself.

bluGillyesterday at 1:13 PM

You realize c++11 is closer in age to C++98 than C++26?

show 1 reply
ginkoyesterday at 12:17 PM

Is it? I'm mostly used to (pre-)C++11 and the only unusual operators I see are ^^T (which I presume accesses the metadata info of T) and [:e:] (which I assume somehow casts the enumerator metadata 'e' to a constant value of T).

And template for but I assume that's like inline for like in zig.

show 1 reply