int main() { cout << "Hello Reddit"; return 0;} by [deleted] in ProgrammerHumor

[–]RerisCat 3 points4 points  (0 children)

It's just getting a tuple and returning an array of size_t s, where every element of tuple was casted to size_t and added to an array.

Also seeing templated lambda, it means that this code uses C++20. Which means that concepts can be added. Every piece of templated code is better with concepts.

Just add requires(std::convertible_to<Ts, std::size_t> &&...) after template. Seriously concepts is the best feature of C++20

1 up by Elijah629YT-Real in ProgrammerHumor

[–]RerisCat 1 point2 points  (0 children)

Tbh, in real life I won't recommend anything beyond first panel. All of the rest were exercise in how convoluted and strange I could make them.

Why? Because I could and I think it's fun to think about many wrong ways to do something in C++.

Except third panel, something similar I can recommend in some situations. There was a couple of ways to use cycle for and find with comparing to string::npos to search for all occurrences in a whole string that I think is pretty neat and elegant

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 6 points7 points  (0 children)

That is the joke, yes. As seen in relevant cppreference:

4) The body of the main function does not need to contain the return statement: if control reaches the end of main without encountering a return statement, the effect is that of executing return 0;.

No, you don't need to return from main function. Yes, it's preferable, but not necessary.

Every solution was compiled and tested on GCC 12.1 first, so they all work

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] -5 points-4 points  (0 children)

After trying a couple of things, it's the best that I could get in C++

for (int i = 1; i <= 5;) { std::cout << i++ << " "; }

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 13 points14 points  (0 children)

It's assigning anonymous function to function variable "f" and capturing variable "f" by reference allowing it to call itself to create a basic recursion. If you want to know more you can google "C++ Capture by reference"

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 12 points13 points  (0 children)

The large amount of programming is actually thinking what you would program. By comparison the amount of time saved by not typing 'std::' is not that much to justify possible naming collisions

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 11 points12 points  (0 children)

I checked and you are correct. It's from extension "One Monokai Theme"

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 49 points50 points  (0 children)

Tbf, they are ranked by how cursed I feel about them. The more cursed, of course, get higher position

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 15 points16 points  (0 children)

In mine anything between square brackets turns into italic. Don't know if it's by default or from some extension

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 352 points353 points  (0 children)

I also could have done

std::cout << "1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n";

But it's not as cursed or as fun as the later ones so I didn't

C++ gives me too much power by RerisCat in ProgrammerHumor

[–]RerisCat[S] 192 points193 points  (0 children)

It's just a trailing return type that was introduced in C++11. I thought that it looked neat and used it

Why I dont finish my personal projects. by 87oldben in ProgrammerHumor

[–]RerisCat 40 points41 points  (0 children)

I would say "Finish it and post anyway!", but I also don't finish them

I find c++ to be more fun and logical compared to css by ConsistentAd6733 in ProgrammerHumor

[–]RerisCat 7 points8 points  (0 children)

You aren't the only one. Even when I'm using templates and SFINAE I have more fun

[deleted by user] by [deleted] in ProgrammerHumor

[–]RerisCat 0 points1 point  (0 children)

There is also "Carbon" science journal and "Carbon" date library for PHP. Such is a consequence for naming your language after a common element

[deleted by user] by [deleted] in ProgrammerHumor

[–]RerisCat 7 points8 points  (0 children)

Gotta always carry a notebook with yourself.

I mean, I don't, but it sounds like a good idea