C++ Logo

std-proposals

Advanced search

Re: [std-proposals] inline function within class definition can define member objects

From: Guillaume Racicot <gracicot42_at_[hidden]>
Date: Sat, 15 Oct 2022 17:24:08 -0300
I think it would be different in that it will keep its value between calls,
just like a non static data member.

The problem is that it would be almost impossible to actually implement and
would make code more error prone and less maintainable. Especially since we
have generators, I see little need for this kind of stuff.

Em sáb., 15 de out. de 2022 17:00, Paolo Di Giglio via Std-Proposals <
std-proposals_at_[hidden]> escreveu:

> > I also propose that the variable "record" would be inaccessible by
> > other methods.
>
> How is this different from a local variable in member function "Method"?
>
> Il giorno sab 15 ott 2022 alle ore 21:50 Frederick Virchanza Gotham via
> Std-Proposals <std-proposals_at_[hidden]> ha scritto:
>
>> I propose that the following:
>>
>> struct Foo {
>>
>> int Method(int arg)
>> {
>> int Foo::record;
>>
>> record = arg;
>>
>> return arg + 4u;
>> }
>> };
>>
>> behaves the same as:
>>
>> struct Foo {
>>
>> int record;
>>
>> int Method(int arg)
>> {
>> record = arg;
>>
>> return arg + 4u;
>> }
>> };
>>
>> There are times when a method needs a simple variable such as a
>> counter or a boolean, and so we then need to add a member variable to
>> the class definition. I'm proposing that we can do all of this inside
>> the body of the method -- so long as the body of the method is inline
>> inside the class definition. I also propose that the variable "record"
>> would be inaccessible by other methods.
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2022-10-15 20:24:20