Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: Antonella Ritorto #636684
    Paul Wicking
    Participant
        Up
        0
        Down
        ::

        On the episode about std::execution on cppcast, one of the guests were also into aerial silk — it’s how I learned the name of it. I wonder (as I believe Timur did); do you find that experiencing the world upside down influences your thinking about programming or mathematics?

        Paul Wicking
        Participant
            Up
            0
            Down
            ::

            AFAIK,  The return type of a function has no effect on function overloading, therefore the same function signature with different return type will not be overloaded.

            Two signatures by the same name, including argument dependent lookup (ADL), may be considered overloads. The same function signature with different return type (return type overload) isn’t valid C++. Consider the following;

            int foo(int a) { return a; }
            double foo(int a) { return static_cast<double>(a); } // compiler will throw an error

            In this case, you’d say the function overloads on the type (or tries to do so as only the return type differs). And that’s not valid C++.

            Paul Wicking
            Participant
                Up
                0
                Down
                ::

                Absolutely, but this isn’t a case of actually overloading the return type (which int foo() vs double foo() would be). What I am curious about is the reason why the compiler isn’t allowed to deduce the return type and match. Because clearly, the function in the example is the same — auto will be deduced to int.

                By the way, if I use trailing return in the definition (and not in the declaration), it compiles as expected, even if auto is in there :)

              Viewing 3 posts - 1 through 3 (of 3 total)