C++17: fixed issues

In C++17 there is couple changes to behavior of things which were already in C++.

1 ) auto x{ 1 } – now it’s int value, not initializer_list.

For a braced-init-list with only a single element, auto
deduction will deduce from that entry;

For a braced-init-list with more than one element, auto
deduction will be ill-formed.

For example:

Standard paper related to this changes: n3922.

Continue reading “C++17: fixed issues”

C++17 Parallel STL (7 new algorithms)

Parallel algorithms implementation it’s a new feature of C++17 standard. Which allow to use simple STL functions in multiple threads.

At the moment (17.07.2018) only one compiler supports Parallel Algorithms. It’s Visual Studio 2017 ( versions 15.3 and higher).

To build C++ projects with parallel STL you need to build with a flag:

/std:c++17

In C++17 we have a new term – Execution policy

It’s the first parameter to parallel functions from STL. It allows you to choose, how can be function executed. To use it you need to include

#include <execution>

Types of execution policy:

std::seq – without using threads or vectorization, sequenced instructions. This is a default value.

std::par – parallel execution with using threads. When using parallel execution policy, it is the programmer’s responsibility to avoid deadlocks.

std::par_unseq – parallel execution using threads and vectorization or migrating across threads(such as by parent-stealing scheduler). Functions with this policy are permitted to execute in unordered fashion in unspecified threads and unsequenced with other threads.

Continue reading “C++17 Parallel STL (7 new algorithms)”

Removed features from C++17

1 – Trigraphs

Trigraphs were removed from C++17 because they are not needed anymore. They were used in C/C++ in 80-s. Because the old coding table not supported all needed symbols ISO/IEC646 like:  # ,  [ ,  ]. etc.

Trigraph Equivalent symbol
??= #
??/ \
??’ ^
??( [
??) ]
??! |
??< {
??> }
??- ~

Also even before C++17 GCC compiler show warning when trigraphs were used, because using trigraphs can turn to unexpected behavior, for example:

Continue reading “Removed features from C++17”