Skip to content

Make std::initializer_list visible.#9

Merged
andreasfertig merged 1 commit intomasterfrom
stdInitializerList
May 21, 2018
Merged

Make std::initializer_list visible.#9
andreasfertig merged 1 commit intomasterfrom
stdInitializerList

Conversation

@andreasfertig
Copy link
Copy Markdown
Owner

With C++11 uniform initialization and initializer lists we cannot
longer easily see whether we are calling a normal constructor or one
which takes a initializer_list. For example:

struct V {
V(int x) {}
V(std::initializer_list x) {}

};

V v{1};
V vv{1, 2};

Surprisingly to some people, in both cases the second constructor, taking
a std::initializer_list, is used.

This change shows the difference by putting the name
std::initializer_list in front of an initializer list.

With C++11 uniform initialization and  initializer lists we cannot
longer easily see whether we are calling a normal constructor or one
which takes a initializer_list. For example:

struct V {
  V(int x) {}
  V(std::initializer_list<int> x) {}

};

V v{1};
V vv{1, 2};

Surprisingly to some people, in both cases the second constructor, taking
a std::initializer_list, is used.

This change shows the difference by putting the name
std::initializer_list<T> in front of an initializer list.
@andreasfertig andreasfertig merged commit c09cc9c into master May 21, 2018
@codecov
Copy link
Copy Markdown

codecov bot commented May 21, 2018

Codecov Report

Merging #9 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #9      +/-   ##
==========================================
+ Coverage   95.36%   95.44%   +0.08%     
==========================================
  Files          40       42       +2     
  Lines        1595     1623      +28     
==========================================
+ Hits         1521     1549      +28     
  Misses         74       74
Impacted Files Coverage Δ
Insights.cpp 95.23% <100%> (ø) ⬆️
StdInitializerListHandler.h 100% <100%> (ø)
StdInitializerListHandler.cpp 100% <100%> (ø)
CodeGenerator.cpp 93.45% <100%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b32685f...a127948. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant