Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News C++17 Feature List is Now Complete, Enters Review

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

This item in japanese

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