• schnurrito
    link
    fedilink
    arrow-up
    5
    ·
    11 hours ago

    auto main() -> int

    What programming language is this even?!

    • HiddenLayer555@lemmy.ml
      link
      fedilink
      English
      arrow-up
      3
      ·
      edit-2
      8 hours ago

      Why would anyone bother writing it like that? That just seems like int main() with extra steps. Like does auto enable some compiler optimisation of the return type that I’m not aware of?

      • Sonotsugipaa@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        2
        ·
        7 hours ago

        Defining the return type that way can be used when dealing with template sorcery - there’s no use for it here though, not even for readability in any way.

      • schnurrito
        link
        fedilink
        arrow-up
        6
        ·
        11 hours ago

        TIL that you can declare return types this way in C++.

          • _____@lemm.ee
            link
            fedilink
            English
            arrow-up
            3
            ·
            8 hours ago

            because explicitly declaring types can be redundant, if the compiler knows a lot of the times you should also know

            also because some types are extremely cursed: see std views/ranges