C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Is a default ctor struct C{C(); }; also a converting constructor

From: connor horman <chorman64_at_[hidden]>
Date: Tue, 9 Jan 2024 13:10:46 -0500
There's no copy-constructor call, though (not even an elided one, I believe
copy-init from RHS of declarator never even tried to call a copy or move
constructor).
copy-list-init doesn't call the copy constructor, it calls the list-init
eligible converting constructor. It's converting from the empty initializer
list, not a value constructed C.

On Tue, 9 Jan 2024 at 12:53, Sean Mayard via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> @connor
>
>
>> You can copy-list-initialize from `{}` if you have a non-explicit default
>> constructor. You thus convert from the empty initializer list to C. Thus, I
>> would call this a converting constructor.
>
>
> But that makes the copy ctor a converting ctor and not the default ctor
> itself. Note that in your example of copy-list-initialize you're actually
> converting an object of that class type to the same class type object.
>
> On Tue, 9 Jan 2024 at 23:14, Giuseppe D'Angelo via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> On 09/01/2024 18:33, connor horman via Std-Proposals wrote:
>> > You can copy-list-initialize from `{}` if you have a non-explicit
>> > default constructor. You thus convert from the empty initializer list
>> to
>> > C. Thus, I would call this a converting constructor.
>>
>> The wording in question has been added by
>>
>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0398r0.html
>>
>> Cf. the core issue:
>>
>> https://cplusplus.github.io/CWG/issues/1518.html
>>
>> Thank you,
>> --
>> Giuseppe D'Angelo
>> --
>> 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 2024-01-09 18:11:00