307
I love Rust (lemmy.blahaj.zone)
submitted 6 days ago by rustyfemboy to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] flying_gel@lemmy.world 33 points 6 days ago

I do appreciate how newer C++ standards have made these kinds of things a lot easier too.

Define all comparison operators with just one one line using C++20

auto operator<=>(const ClassName&) const = default;

[-] xor 43 points 6 days ago

It's nice that this exists these days, but my god is it horrendously unreadable at a glance

[-] Ephera@lemmy.ml 5 points 5 days ago

It makes it look like they're just adding random noise to avoid colliding with existing syntax. Maybe they can try a UUID next time...

[-] flying_gel@lemmy.world 5 points 5 days ago

It makes perfect sense actually. I did write another comment here if you are interested.

This is how operator overloads were written going back to the initial version of C++ back in 1985. The only new thing is that we can now add = default to get the compiler to generate a default implementation that compares all the member variables for you.

load more comments (11 replies)
this post was submitted on 15 Nov 2024
307 points (100.0% liked)

Programmer Humor

32536 readers
515 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS