Date: Tue, 24 Jan 2023 23:52:40 +0100
This will be very much useless. The reason is that you need the return type
for something you do to obtain the return value. Because of this 99% of the
time your return type will be dependent on itself.
On Tue, Jan 24, 2023, 23:47 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Tue, Jan 24, 2023 at 10:25 PM Jason McKesson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> > Because the language says that it is.
> >
> > The member access works because all member functions defined in the
> > class definition are effectively placed after the end of that class
> > definition. Therefore, they get to access class members that were not
> > yet defined.
> >
> > Referring to things in a function that haven't been defined yet isn't
> allowed.
>
>
> I feel like I'm pointing at water here and saying "water is wet" but
> anyway . . . I'll spell it out:
>
> 'return_t' can be determined from the return statement, even if the
> return statement comes after the first use of 'return_t'.
>
> So when the compiler sees the following:
>
> template<typename T, typename A>
> auto Func(T obj0, A obj1)
> {
> return_t obj;
> return obj0 + obj1;
> }
>
> It picks out the return statement: obj0 + obj1
>
> It wraps it in decltype: decltype(obj0 + obj1)
>
> and then it makes a new type: typedef decltype(obj0 + obj1) return_t;
>
> So here's what the compiler turns it into:
>
> template<typename T, typename A>
> auto Func(T obj0, A obj1)
> {
> typedef decltype(obj0 + obj1) return_t;
> return_t obj;
> return obj0 + obj1;
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
for something you do to obtain the return value. Because of this 99% of the
time your return type will be dependent on itself.
On Tue, Jan 24, 2023, 23:47 Frederick Virchanza Gotham via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> On Tue, Jan 24, 2023 at 10:25 PM Jason McKesson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> > Because the language says that it is.
> >
> > The member access works because all member functions defined in the
> > class definition are effectively placed after the end of that class
> > definition. Therefore, they get to access class members that were not
> > yet defined.
> >
> > Referring to things in a function that haven't been defined yet isn't
> allowed.
>
>
> I feel like I'm pointing at water here and saying "water is wet" but
> anyway . . . I'll spell it out:
>
> 'return_t' can be determined from the return statement, even if the
> return statement comes after the first use of 'return_t'.
>
> So when the compiler sees the following:
>
> template<typename T, typename A>
> auto Func(T obj0, A obj1)
> {
> return_t obj;
> return obj0 + obj1;
> }
>
> It picks out the return statement: obj0 + obj1
>
> It wraps it in decltype: decltype(obj0 + obj1)
>
> and then it makes a new type: typedef decltype(obj0 + obj1) return_t;
>
> So here's what the compiler turns it into:
>
> template<typename T, typename A>
> auto Func(T obj0, A obj1)
> {
> typedef decltype(obj0 + obj1) return_t;
> return_t obj;
> return obj0 + obj1;
> }
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2023-01-24 22:52:55