C++17: Modifications to existing features (Part 1)

Single-argument static_assert

In C++17 static_assert message was changed to optional, and it’s possible create static_assert without message.

For example:

Nested namespace declarations

Nested namespace declarations allows to declare nested name space without declaring base namespaces.

For example in C++14:

and in C++17:


Allow typename in template template parameters

Before C++17 was allowed only keyword class in template template parameter.

So now code may look like this:


Range-based for takes separate begin/end types

In C++17 range loop was changed from :

to :

and it’s allows to have begin() and end() iterators , two different types.

And next example can be compiled succesful:

TS: p0184r0

Pack expansion in using-declarations

Variadic templates were introduced in C++11, but using declarations didn’t worked with pack expansion. Now it’s possible and quite useful, make code much more clear.

For example overloading lambdas:


Leave a Reply

Your email address will not be published.