• 0 Posts
  • 21 Comments
Joined 1 year ago
cake
Cake day: July 8th, 2023

help-circle

  • 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.


  • Maybe to a non C++ dev, but a lot of C++ is probably incomprehensible to a non C++ dev, just like there are other laguages that are incomprehensible to C++ devs. To me it makes perfect sense as it works just like all the other operator overloads.

    auto - let the compiler deduce return type

    operator<=> - override the spaceship operator (pretty sure it exists in python too)

    (const ClassName&) - compare this class, presumably defined in Class name, with a const reference of type Class name, i.e. its own type.

    const - comparison can be made for const objects

    = default; - Use the default implementation, which is comparing all the member variables.

    An alternate more explicit version, which is actually what people recommend:

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

    if I just want to have less than comparison for example I would:

    This one makes it explicit that you’re comparing two Class name objects.

    if I just want to have less than comparison for example I would:

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

    If I need to compare against another class I could define: auto operator<(const ClassName&, const OtherClass&)


  • You mean copy/move constructor and assignment operator?

    Unless you have any special handling the ones generated by the compiler automatically should work just fine. But if you do have to define them for some reason (which is becoming increasingly rare) you would need to define both if you need both copy/move construction and copy/move assignment.





  • I went from using slackware late 90s early 00 to Mac OSX in early/mid 00. When coming back to Linux late 00 early 10s I was so disappointed in the Linux distros. I tried Ubuntu but was very disappointed in the lack of newer versions of third party software in their repo. Tried Arch for a while and while packages were up to date, every now and then the OS updates would mess something up and I had to start troubleshooting.

    It might be better now, but I eventually gave up and went to FreeBSD about 10 years ago. Stable base and separate up to date third party feels like the best of both worlds. Not sure if any llinux distro offers something like that now. No snap, no flatpack, just a base os and up to third party date packages.







  • It’s not necessarily better, some things are a personal preference. Though some might be able to list some technical pros and cons.

    Some things I appreciate are:

    • base systems and packages are completely separate. Packages and their configuration goes in /usr/local/ No where else. (Thought they might write to /var/ )
    • bsd init, not systemd. Feels more home to me as a late 90s slackware user.
    • first class zfs support. Linux has caught up lately, especially now that there is a shared zfs codebase for both Linux and FreeBSD. When I switched to FreeBSD on my home server ~10 years ago that wasn’t the case.


  • After a hiatus in Mac and windows land, I came back into Linux a with similar wishlist.

    It’s quite a diversion, but I actually went with FreeBSD. Now it’s not Linux but with the separation of base system and packages, you get a stable base that is released at a pretty fixed consistent schedule.

    For packages you can pick from quarterly or weekly update schedule, so you can have a stable base OS with bleeding edge software. The binary package manager is easy to use, but if you want more control you can opt for building from source as well.

    The init system is BSD based so all main config goes into a single rc.conf file, very easy to understand and work with.

    Most mainstream applications such as Firefox, postgresql, nginx etc are just a pkg install away and it natively supports zfs (even as root fs) which was one of the reasons I got really interested in it 10 years ago.

    Of course, there is software, especially some younger projects that don’t support FreeBSD. So while there are thousands of packages available, some Linux only applications won’t work.

    Personally, I would pick FreeBSD any time that the software I require supports it. I only run Linux (settled on pop is for now) if the software I need requires it.