A “sorted view”--Nick Athanasiou

Sorting can be done many ways.

A “sorted view”

by Nick Athanasiou

From the article:

This installment elaborates on the creation of a “sorted_view” utility. The “References” section contains links to the complete code; throughout the article, we provide demos and snippets to showcase and explain the implementations. The section on modernizing the code contains real world applications of the following C++17 features:

  1. structured bindings
  2. template argument deduction for class templates

Order Your Members

How ordering members can impact performance.

Order Your Members

by Jonas Devlieghere

From the article:

The article highlights the impact that different choices regarding the ordering of members in a struct can have on the performance of your code. A lot can be achieved by taking into account some general guidelines.

(Not) detecting bugs--Andrzej Krzemieński

Undefined behaviour can be dangerous.

(Not) detecting bugs

by Andrzej Krzemieński

From the article:

The following code contains a bug. A developer has spent quite some time looking for the source. The intent of this code is to iterate over two vectors simultaneously, from the first up to the one-before-last element. Thus the most interesting tools that will be employed will be boost::zip_iterator and std::prev.

#include <boost/iterator/zip_iterator.hpp>
#include <boost/tuple/tuple.hpp>
#include <vector>

using zip_iter = boost::zip_iterator<
                   boost::tuple<
                     std::vector<int>::iterator,
                     std::vector<int>::iterator
                   >
                 >;
int main()
{
  std::vector<int> v1 = {1, 2, 3, 4, 0};
  std::vector<int> v2 = {2, 3, 5, 7, 0};
    
  zip_iter beg {boost::make_tuple(v1.begin(), v2.begin())};
  zip_iter end {boost::make_tuple(v1.end(), v2.end())};
  
  auto process = [](zip_iter::reference){};
  std::for_each(beg, std::prev(end), process);
}

Add a const here, delete a const there…--Bruce Dawson

Why constness is important in one article. Can be even better with constexpr.

Add a const here, delete a const there…

by Bruce Dawson

From the article:

I just completed a series of changes that shrunk the Chrome browser’s on-disk size on Windows by over a megabyte, moved about 500 KB of data from its read/write data segments to its read-only data segments, and reduced its private working set by about 200 KB per-process. The amusing thing about this series of changes is that they consisted entirely of removing const from some places, and adding const to others. Compilers be weird...

Generate lambdas for clarity and performance--Björn Fahller

A nice way to avoid code duplication and gain in readability:

Generate lambdas for clarity and performance

by Björn Fahller

From the article:

Higher order functions, functions that operate on other functions or returns functions, are familiar to those who have had some experience with functional programming, but they often seems magical to those who have not. Some of those with experience of using higher order functions have a gut feeling that they are expensive to use and prefer to avoid them...

C++ User Group Meetings in January

The January listing of upcoming User Group meetings!

C++ User Group Meetings in January

by Jens Weller

From the article:

The new year has begun, and as I just returned the listing of the User Group Meetings is a bit late...

Yet still, 37 Meetings in January are listed, 7 of them in Austin, as there is a study group for Modern C++ now.

There are 3 new C++ User Groups: Nashua, NH, Vienna (Qt), Austin (Mentoring & Study Group).

C++ Status at the end of 2016 -- Bartlomiej Filipek

What happened in 2016 in the C++ world?

C++ Status at the end of 2016

by Bartlomiej Filipek

From the article:

Let’s now focus on the main topic from this year.During the ISO meeting in Oulu (June), the Committee accepted the draft for C++17. This is definitely not a minor release since a lot of features were added!