-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix inconsistent choice of init list constructor #921
fix inconsistent choice of init list constructor #921
Conversation
|
8f6a3c8
to
c854e44
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #921 +/- ##
========================================
Coverage 92.95% 92.96%
========================================
Files 85 85
Lines 8052 8056 +4
========================================
+ Hits 7485 7489 +4
Misses 567 567
Continue to review full report in Codecov by Sentry.
|
Hey good idea ! |
|
¿What if caller actually wants to produce an array with a single item? Some people may already be using code that supplies
And proposed change will break this code when only a single item is supplied. Also i'm not sure about |
The proposed change is the only way I could come up with that would make the behaviour consistent. The problem of behaviour being inconsistent between compilers have been haunting us for years. That being said, creating an array from one element init list is very easy:
or
|
How could there be a reference to an object that does not exist yet? |
However you make behavior of constructor taking
In case if |
No, it will not make it inconsistent. It will be consistent with documented behaviour (which reminds me that I should have amended documentation). And yes, it will break existing code. So, I'm leaning towards temporary providing a macro to disable the new behaviour.
Ok, just to be sure I will replace |
c854e44
to
31400c9
Compare
|
31400c9
to
a00c90b
Compare
|
a00c90b
to
85df13d
Compare
|
On some compilers value{x} invokes initializer_list constructor, on others it is equivalent to value(x). This is very problematic, but this isn't something we can fix. On the other hand, we CAN make init list construction to be equivalent to value(x), if the size of init list is one. This commit does exactly that.
85df13d
to
25e740d
Compare
|
On some compilers
value{x}
invokesinitializer_list
constructor, on others it is equivalent tovalue(x)
. This is very problematic, but this isn't something we can fix. On the other hand, we can make init list construction to be equivalent tovalue(x)
, if the size of init list is one. This commit does exactly that.Fix #920