• Skip to primary navigation
  • Skip to main content
  • Skip to footer
Scinonova logo
  • Start
  • Om oss
  • Karriär
  • Blogg
  • Kontakt
  • Svenska

6 Useful New Features in C++17 – Part 1

29 augusti, 2018 by Scionova

In this 5 parts of blog series, Patrik from Scionova will talk about useful features in C++17, that can help you write better codes. Every Monday and Thursday new posts in this series will come out.

Every now and again, I have some time to spare in which I try to brush up or gain some new knowledge in different areas. In the previous project I was working in, C++14 was used as the latest approved revision of the C++ standard. But the C++17 is (almost entirely) supported by commonly used compilers and can be used in new projects. Therefore, I was thinking that this time it might be a good idea to familiarise myself with C++17 revision.

And it was good stuff that I was finding, so why not share these findings with my colleagues, and why not everyone? So that is what I did,  and the following is a small set of features of the C++17 revision that can help you write better and more maintainable code. Keep in mind though that there are a lot more features in this revision, here is a compilation of all changes between C++14 and C++17.

Short hand for nested namespace declaration

Large projects I’ve been working in have had a lot of nested namespaces, in the format like company::area::component. This pattern is also found in Android Open Source Project, e.g., android::hardware::wifi::V1_0::IWifi. C++17 supports a short hand in writing these Nested namespace on one single, neat looking line:

What’s more is that one can attach attributes to entire namespaces as well. One convenient use case could be to deprecate an entire namespace in an API.

Compiler Support

These features are all fully supported by GCC, MSVC, and clang. Below follows a table showing which version enables support for each feature respectively.

For more a detailed matrix with more compilers and all features of C++17 listed, follow this link

READ PART 2 “6 Useful New Features in C++17” HERE.

 

// Patrik Ingmarsson

Filed Under: Programmering

Improve your coding skills

2 July, 2018 | Scionova
Peter give his best tip on how you can improve your coding…

6 Useful New Features in C++17 - Part 1

29 August, 2018 | Scionova
In this 5 parts of blog series, Patrik from Scionova will talk…

6 Useful New Features in C++17 - Part 2

3 September, 2018 | Scionova
This is the second part of the series "6 Useful New Features…

6 Useful New Features in C++17 - Part 3

6 September, 2018 | Scionova
This is the third part of the series "6 Useful New Features…

6 Useful New Features in C++17 - Part 4

11 September, 2018 | Scionova
This is the fourth part of the series "6 Useful New Features…

6 Useful New Features in C++17 - Part 5

13 September, 2018 | Scionova
Constexpr lambdas Since C++11 we are able to use the constexpr specifier…

Footer

Göteborgskontoret


Theres Svenssons Gata 13,
417 55 Göteborg

Varbergskontoret


Kungsgatan 28b,
432 44 Varberg

Gasell