While the article describes why you'd want this abomination, honestly, I'd rather opt for the copy-pasted code
T& at(size_t x, size_t y) { return data.at(y * X + x); }
const T& at(size_t x, size_t y) const { return data.at(y * X + x); }
as something that's actually human-legible while also providing const-correctness. If the implementation is actually complicated enough, then sure, use the const_cast variation, but hide it away in a .cc file. This feels like a contrived example to show off new language features.That said, I'd also rather use std::mdspan [0] if I had C++23 available, and not implement my own Matrix struct by hand.
All the other stuff you mentioned as far as I can tell is C++11 too, so it looks like you haven't used c++ for a long time.
I get why it's that way, backward compatibility. The problem is, the original way, the path of least resistance, is now effectively deprecated, but it's the official syntax.
char* s = malloc(size);
is considered bad code. I get why. But, in a "good language" the default would do the right thing and I'd only escape into bad code by extra work so that all the easiest code to write did the right thing by default.C++ is trying to fix all that old bad code by coding standards and linters but I don't want to have to type a bunch of boilerplate I need to memorize to do the right thing. I want the right thing to be the most obvious, no brain cells required path.
Of course if the language was designed again from scratch it might settle on a different local optimum.
From your example above, the only bit I really dislike is the handling of universal references (forward and &&), but that's the best that programmers better than me were able to retrofit onto the language, so eh.
ok that's pretty goofy
What bugs me is that if I ever need to update my resume again, I'll need to take C++ off of it. This time for sure. It's been there since the 1990s, but it has become increasingly fraudulent for me to leave C++ on my list of qualifications since then.
It kind of sucks to lose a hard-won skill... not because I got old and forgetful (which will happen, but not just yet), or because I stopped using it daily (I never stopped), but because they changed what it meant to "know C++." The code you posted might as well be Brainfuck or Perl or line noise or something.
C++ is simply not a C-derived language anymore, and we need to stop pretending otherwise. It was never about the brackets and semicolons, it was about the fact that you could read and understand it as a newbie with no more than a couple weeks' exposure. If all that crap is really necessary, then something went very wrong somewhere at some point, and went unaddressed afterward, and now it's too late.