BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

C++17 Feature List is Now Complete, Enters Review

| by Sergio De Simone on Jul 06, 2016. Estimated reading time: 1 minute |

During the last meeting in Oulu, Finland, the ISO C++ committee completed the definition of the C++17 feature list. At the meeting, a number of new language and library features were approved, including constexpr if, template <auto>, structured bindings, and others.

As committee member Jens Weller writes, now that the feature list has been closed, a review period will start:

The next two meetings mostly will process reviews, feedback and issues flagged by national bodies. This will not add new things to the standard, but can have minor or major changes.

Among the features that were added to C++17 in the last committee meeting in Oulu, Weller highlights the following:

  • std::variant, which provides a safe, generic, stack-based discriminated union container.

  • if constexpr(expression), which can be regarded as C++ version of a compile-time if.

  • Template auto, which allows to declare non-type template arguments with auto. This will allow to write:

      template <auto value> void f() { }
      f<10>();        // deduces int
    

    Herb Sutter stresses the various possibilities opened up by this feature, such as writing a function template that includes all the special cases of its algorithm right within its body and not through a set of template specializations.

  • Structured bindings, which makes it possible to declare and initialize multiple variables from a tuple:

    tuple<T1,T2,T3> get_tuple();
    auto [a , b , c] = get_tuple();
    
  • variable declarations in if and switch, similarly to what the for loop already allowed:

    map<int,string> mymap;
    if (auto result = mymap.insert(value); result.second) {
    // insert succeeded, and result is valid for this block
    use(result.first);  // ok
    // ...
    }
    

Additionally, Sutter mentions new features that deserve to be highlighted, including:

The list above only includes new features that have been approved in the last committee meeting, but the list of features that will be part of the new C++17 standard is much longer. A useful resource to get an overview of what the new standard should include at the end of the review process can be found in this Stack Overflow thread.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT