Date: Thu, 22 Aug 2019 22:01:00 +0200
Hi,
with C++17 guaranteed copy initialization, the distinction between direct
list initialization and copy list initialization has become illusory.
When we initialize a variable with both of these syntaxes:
1) T a{ param };
2) T a = { param };
We always create a variable of known type, so there is no point in making
these syntaxes behave differently (currently the only known difference to
me is the explicit constructor).
So first proposal is merging direct and copy list initialization into one.
Second idea is fixing the ambiguities with auto construction.
auto a{1}; // a is of type int
auto a = { 1 }; // a is std::initializer_list<int>
I propose to acknowledge the truth, these are ambiguous, let's just make
list initialization of auto ill formed.
This will force users to use following unambiguous syntaxes:
auto a = 1;
or
std::initializer_list a = { 1 };
Regards,
Maciej
with C++17 guaranteed copy initialization, the distinction between direct
list initialization and copy list initialization has become illusory.
When we initialize a variable with both of these syntaxes:
1) T a{ param };
2) T a = { param };
We always create a variable of known type, so there is no point in making
these syntaxes behave differently (currently the only known difference to
me is the explicit constructor).
So first proposal is merging direct and copy list initialization into one.
Second idea is fixing the ambiguities with auto construction.
auto a{1}; // a is of type int
auto a = { 1 }; // a is std::initializer_list<int>
I propose to acknowledge the truth, these are ambiguous, let's just make
list initialization of auto ill formed.
This will force users to use following unambiguous syntaxes:
auto a = 1;
or
std::initializer_list a = { 1 };
Regards,
Maciej
Received on 2019-08-22 15:03:14