7 Features of C++17 that will simplify your code

fenbf
584.9K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Introduction

C++17 features, simplifications

With each C++ standard, we aim for simpler, cleaner and more expressive way to code. C++17 offers several "big" language features that should make our code nicer. Today, I tried to pick seven things that make your code more compact right off the bat.

  1. Structured bindings/Decomposition declarations
  2. Init-statement for if/switch
  3. Inline variables
  4. constexpr if
  5. Fold expressions
  6. Template argument deduction for class templates
  7. Declaring non-type template parameters with auto

This article is adapted version of C++17 in details: Code Simplification and C++17 in details: Templates from my blog.

I've added more examples, and what's more important most of the code can be invoked in the browser! You can play with the samples and experiment with the new language features.

Documents & Links

First of all, if you want to dig into the standard on your own, you can read the latest draft here:

N4659, 2017-03-21, Working Draft, Standard for Programming Language C++ - the link also appears on the isocpp.org.

And you can also grab my list of concise descriptions of all of the C++17 language features:

Download a free copy of my C++17 Cheat Sheet!

It's a one-page reference card, pdf.

More reference links:

C++17 Books:

OK, let's discuss the features!

Click below on the "Structured Bindings..."

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content