C++17: fixed issues

In C++17 there is couple changes to behavior of things which were already in C++.

1 ) auto x{ 1 } – now it’s int value, not initializer_list.

For a braced-init-list with only a single element, auto
deduction will deduce from that entry;

For a braced-init-list with more than one element, auto
deduction will be ill-formed.

For example:

Standard paper related to this changes: n3922.

2) static_assert without message

Before it was possible create static_assert only with message like:

and now message is optional parameter.


3) Changed Technical Specification for range-loop

The existing range-based for loop is over-constrained. The end iterator is never incremented,
decremented, or dereferenced. Requiring it to be an iterator serves no practical purpose.



Now begin() and end() can have different types, and it allows to write code like this:

Logic from range-loop can be moved to structure or class.

Standard paper related to this changes: p0184.




Leave a Reply

Your email address will not be published.