I’ve always found C++'s “trend” of handling normal or non-exceptional system errors with exceptions lackluster (and I’m being charitable). Overall trimming things down to (basically) passing around a couple integers and telling the user to check their manual is much better, much less error prone, and much more efficient and deterministic.

    • lambaliciousOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      5 个月前

      Yeah they are quite good and they do basically fall under “just wrap an integer”.

    • benni@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      5 个月前

      Same, I also like giving this the [[nodiscard]] attribute if I want to make sure that it’s not ignored.

        • benni@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          5 个月前

          I’m mixed on this one, because sometimes you’ll want to call a function for its side effects without caring about the return value. E. g. container methods returning an iterator that shows you where the side effect took place.

              • SpaceNoodle@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                edit-2
                5 个月前

                Neat, I learned something. I keep smashing C and C++ together on my head.

                The notes on that page do suggest the same method I did, however.

              • lambaliciousOP
                link
                fedilink
                English
                arrow-up
                1
                arrow-down
                1
                ·
                5 个月前

                First: it’s not new, it’s been around since C++03.

                Second… it’s not even that great. It’s more characters to type and you have to deal with stds and colons. (void) is a classic and works everywhere.

                But hey, at least it’s not static_cast<void>(...).