• schnurrito
    link
    fedilink
    arrow-up
    6
    ·
    4 months ago

    auto main() -> int

    What programming language is this even?!

      • schnurrito
        link
        fedilink
        arrow-up
        6
        ·
        4 months ago

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

          • _____@lemm.ee
            link
            fedilink
            English
            arrow-up
            5
            ·
            4 months 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

    • HiddenLayer555@lemmy.ml
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      4 months 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
        3
        ·
        4 months 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.