C++17

Along with the new features added to the language and the standard library in C++17, there are also existing features that have been either removed (after being deprecated in a previous version) or deprecated so they would be removed sometime in the future. Although not complete, the following tables list the most important of these removed or deprecated features.

Read More C++17 removed and deprecated features

Transform-reduce is a pattern in which a set of data is first modified by applying a transformation on each of the elements and then it is reduced to a single value. In C++, this can be implemented straightforwardly with std::transform and std::accumulate. In C++17, an alternative for std::accumulate is available; std::reduce sums a range of elements just like std::accumulate, except that it does so out of order. That means you cannot use it with operators that are not communicative or associative (including overloads of operator+ that don’t exhibit these properties). On the other hand, there is yet another algorithm called std::transform_reduce that applies a functor to all the elements of a range and then reduces them, all in an out of order manner. And then, there are also parallel versions of these algorithms. In this post, I will try to compare the performance of these possible alternatives for implementing transform-reduce.

Read More Transform and reduce alternatives

I am pleased to announce that my book on modern C++ programming has been published by PacktPub. The book is called Modern C++ Programming Cookbook and can be ordered at packtpub.com and Amazon. The ISBN of the book is 9781786465184. The complete table of contents is available below. The book is organized in recipes, much…

Read More My book Modern C++ Programming Cookbook has been published

Initialization of variables in C++ can have several forms: default initialization: std::string s; value initialization: std::string s{}; direct initialization: std::string s(“demo”); copy initialization: std::string s = “demo”; list initialization: std::string s{‘d’, ‘e’, ‘m’, ‘o’}; aggregate initialization: char s[5] = {‘d’, ‘e’, ‘m’, ‘o’}; reference initialization: char& c = s[0]; C++11 introduced a generalized syntax for…

Read More C++17 New Rules For auto Deduction From braced-init-list

The new Visual C++ 2017, currently in release candidate phase, provides a series of updates and fixes to both the C++ compiler and the standard library. A comprehensive list of these improvements is available at What’s New for Visual C++ in Visual Studio 2017 RC. In this article, I want to shortly look at the…

Read More New standard library features in Visual C++ 2017 RC