Date: Mon, 13 May 2024 23:08:55 +0800
Yes, delegating constructors should not be allowed to pass-by-value. It is
one of the cases of the rule.
Rhidian De Wit <rhidiandewit_at_[hidden]> 于2024年5月13日周一 22:39写道:
> If I understand correctly, you want to disable pass-by-value semantics?
> I'm not sure what you're referring to in your code example as well.
> Or, are you trying to say that delegating constructors should not be
> allowed to pass-by-value?
>
> Op ma 13 mei 2024 om 16:36 schreef David wang via Std-Proposals <
> std-proposals_at_[hidden]>:
>
>> Hi everyone.
>>
>> In C++, we can pass an object of the same type by value to the
>> constructor of the class, which results in a copy of the same type or its
>> subtype being required.
>>
>> The sequence of constructor calls can be greatly optimized by disabling
>> copying of the same type or its subtypes before constructing an object.
>> I'm confused why C++ doesn't disable it.
>>
>> That is, when we are going to do something(constructing an object via
>> some constructor), the prerequisite is that we need to do something of the
>> same kind. For example, the derived(*int* i, derived that) and
>> *template* <*typename* T> base(T x) in the code snippet below.
>>
>> *struct* base {
>>
>> base() {}
>>
>> *template* <*typename* T> base(T x) {}
>>
>> };
>>
>> *struct* derived : *public* base {
>>
>> derived(){}
>>
>> derived(*int* i, derived that): base(that) {}
>>
>> derived(derived& that): base(that) {}
>>
>> };
>>
>> *int* main() {
>>
>> derived d1;
>>
>> derived d2(d1);
>>
>> *return* 0;
>>
>> }
>>
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>
>
> --
> Rhidian De Wit
> Software Engineer - Barco
>
one of the cases of the rule.
Rhidian De Wit <rhidiandewit_at_[hidden]> 于2024年5月13日周一 22:39写道:
> If I understand correctly, you want to disable pass-by-value semantics?
> I'm not sure what you're referring to in your code example as well.
> Or, are you trying to say that delegating constructors should not be
> allowed to pass-by-value?
>
> Op ma 13 mei 2024 om 16:36 schreef David wang via Std-Proposals <
> std-proposals_at_[hidden]>:
>
>> Hi everyone.
>>
>> In C++, we can pass an object of the same type by value to the
>> constructor of the class, which results in a copy of the same type or its
>> subtype being required.
>>
>> The sequence of constructor calls can be greatly optimized by disabling
>> copying of the same type or its subtypes before constructing an object.
>> I'm confused why C++ doesn't disable it.
>>
>> That is, when we are going to do something(constructing an object via
>> some constructor), the prerequisite is that we need to do something of the
>> same kind. For example, the derived(*int* i, derived that) and
>> *template* <*typename* T> base(T x) in the code snippet below.
>>
>> *struct* base {
>>
>> base() {}
>>
>> *template* <*typename* T> base(T x) {}
>>
>> };
>>
>> *struct* derived : *public* base {
>>
>> derived(){}
>>
>> derived(*int* i, derived that): base(that) {}
>>
>> derived(derived& that): base(that) {}
>>
>> };
>>
>> *int* main() {
>>
>> derived d1;
>>
>> derived d2(d1);
>>
>> *return* 0;
>>
>> }
>>
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>
>
> --
> Rhidian De Wit
> Software Engineer - Barco
>
Received on 2024-05-13 15:09:10