Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Linux
  3. TIL that you can declare return types this way in C++.

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

Scheduled Pinned Locked Moved Linux
5 Posts 5 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S This user is from outside of this forum
    S This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #1

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

    Q 1 Reply Last reply
    0
    • System shared this topic on
    • S [email protected]

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

      Q This user is from outside of this forum
      Q This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #2

      I never understood why they added that

      B _ F 3 Replies Last reply
      0
      • Q [email protected]

        I never understood why they added that

        B This user is from outside of this forum
        B This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #3

        Among other things it lets you define the return type in terms of the arguments to the function.

        1 Reply Last reply
        0
        • Q [email protected]

          I never understood why they added that

          _ This user is from outside of this forum
          _ This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • Q [email protected]

            I never understood why they added that

            F This user is from outside of this forum
            F This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #5

            They're useful for templates because the trailing version is resolved later

            1 Reply Last reply
            0
            • System shared this topic on
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups