C++ Logo

std-discussion

Advanced search

Re: List initialize from tuple

From: Peter C++ <peter.cpp_at_[hidden]>
Date: Sat, 13 Feb 2021 20:26:44 +0100
just a tiny question to the knowing on this thread, for aggregates with one element to initialize, does () provide the same narrowing protection than using braces?

getting narrowing protection through constructors requires expert-level shenanigans.

Sent from Peter Sommerlad's iPad
+41 79 432 23 32

> On 13 Feb 2021, at 16:46, Ville Voutilainen via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> On Sat, 13 Feb 2021 at 15:31, Jefferson Carpenter via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
>>
>>> On 2/13/2021 9:29 AM, Ville Voutilainen via Std-Discussion wrote:
>>> On Sat, 13 Feb 2021 at 10:28, Bo Persson via Std-Discussion
>>> <std-discussion_at_[hidden]> wrote:
>>>> As Ville points out, the solution apparently was to generalize the ()
>>>> initializer, not to change make_from_tuple.
>>>
>>> Right, that made existing factory functions Just Work, instead of
>>> having them opt into some
>>> new facility that we might entertain adopting. I.e.
>>> https://isocpp.org/files/papers/D2157R0.html
>>> I should reformat that a bit and add make_from_tuple to it and publish it.
>>>
>>
>> Thanks! Definitely take my questions as questions only, not as anything
>> approaching a proposal. I know C++ pretty well, but not nearly well
>> enough to know the spot to make a change to improve the language.
>
> No worries. The long and winding history of this problem has had it suggested
> to be solved in the library facilities by first checking whether the
> type is constructible
> and then falling back to brace-init, by using brace-init for
> aggregates, by using
> a proposed deferred-evaluation mechanism, etc. etc. P0960 was written because
> various people, me included, wanted the paren-init to Just Work,
> without necessitating
> any of the aforementioned techniques in the standard library
> facilities and especially
> in user code written by non-experts.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2021-02-13 13:26:50