Date: Wed, 16 Aug 2023 23:08:46 +0300
Not only that but if you use template deduction (at least on msvc) this:
std::array arr = {
something1,
something2,
something3,
};
also works.
On Wed, Aug 16, 2023 at 10:23 PM Edward Catmur via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> https://en.cppreference.com/w/cpp/container/array/to_array
>
> On Wed, 16 Aug 2023 at 14:07, Frederick Virchanza Gotham via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
>> I use source code management systems like Git and SVN, and so when I'm
>> making a code change, it's nice when the diff is minimal.
>>
>> If I have a C-style array, I can do the following:
>>
>> SomeType const arr[] = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> Let's say my colleague adds a line between something1 and something2,
>> while simultaneously I add three lines between something3 and something4.
>> There won't be a clash when we try to push to the remote repository. But
>> let's say it was:
>>
>> array<SomeType,3u> = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> My colleague wants to change that first line to "array<SomeType,4u>",
>> while I want to change it to "array<SomeType,6u>".
>>
>> And even if we don't have two or more people working on the same code
>> base, it's just plain convenient not to have to write the size of the array.
>>
>> Can we devise a way of making the following possible:
>>
>> array<SomeType> = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> Perhaps something along the lines of:
>>
>> template<typename T, std::size_t len>
>> class array {
>> array(std::initializer_list<T> list -> len);
>> };
>>
>> --
>> 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
>
std::array arr = {
something1,
something2,
something3,
};
also works.
On Wed, Aug 16, 2023 at 10:23 PM Edward Catmur via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> https://en.cppreference.com/w/cpp/container/array/to_array
>
> On Wed, 16 Aug 2023 at 14:07, Frederick Virchanza Gotham via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
>> I use source code management systems like Git and SVN, and so when I'm
>> making a code change, it's nice when the diff is minimal.
>>
>> If I have a C-style array, I can do the following:
>>
>> SomeType const arr[] = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> Let's say my colleague adds a line between something1 and something2,
>> while simultaneously I add three lines between something3 and something4.
>> There won't be a clash when we try to push to the remote repository. But
>> let's say it was:
>>
>> array<SomeType,3u> = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> My colleague wants to change that first line to "array<SomeType,4u>",
>> while I want to change it to "array<SomeType,6u>".
>>
>> And even if we don't have two or more people working on the same code
>> base, it's just plain convenient not to have to write the size of the array.
>>
>> Can we devise a way of making the following possible:
>>
>> array<SomeType> = {
>> something1,
>> something2,
>> something3,
>> };
>>
>> Perhaps something along the lines of:
>>
>> template<typename T, std::size_t len>
>> class array {
>> array(std::initializer_list<T> list -> len);
>> };
>>
>> --
>> 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 2023-08-16 20:08:59