Applying a permutation to a vector, part 1--Raymond Chen

It seems a simple problem, yet...

Applying a permutation to a vector, part 1

by Raymond Chen

From the article:

Suppose you have a vector indices of N integers that is a permutation of the numbers 0 through N − 1. Suppose you also have a vector v of N objects. The mission is to apply the permutation to the vector. If we let v2 represent the contents of the vector at the end of the operation, the requirement is that v2[i] = v[indices[i]] for all i...

A new way of blogging about C++--Yehonathan Sharvit

A very interesting plugin for our blogs:

A new way of blogging about C++

by Yehonathan Sharvit

From the article:

This blog post is about to show a new way of blogging about C++.

Look at a typical blog post about C++: The post usually presents a couple of code snippets. As I see it, there are two pains with code snippets:

  1. they contain the input and the output but not the actual evaluation of the input
  2. it’s impossible for the reader to modify the output...

string_view odi et amo--Marco Arena

string_view has recently joined the C++ standard and it can dramatically help your daily job. In this article, after introducing how it works, I show and discuss a few common pitfalls I have met in the last years:

string_view odi et amo

by Marco Arena

From the article:

string_view-like wrappers have been successfully used in C++ codebases for years, made possible by libraries like boost::string_ref. I think all of you know that string_view has joined the C++ standard library since C++17...

My take on variant--Jonathan Müller

An interesting point of view and implementation of a variant in one article!

My take on variant

by Jonathan Müller

From the article:

C++17 is going to add std::variant. To quote the linked documentation, it is a “type-safe union”. A union is like a struct, but can only store one member at a time. This has many applications, but sadly it doesn’t mix well with non-trivial types, you have to call the destructor yourself etc. Furthermore, nothing prevents you from accessing a union member that isn’t active.

std::variant fixes that. It correctly calls the destructor when switching the active member, it prevents invalid access, etc. However, I’m not quite happy with it and I needed an implementation now. So I’ve decided to implement my own variant as part of my type_safe library.

It was a fun challenge and since my previous attempt was two years ago, I could improve it a lot. Let’s go through some of my design decisions.

Folding Functions--Sumant Tambe

Let's use those fold operators!

Folding Functions

by Sumant Tambe

From the article:

In the last post we looked at basic usage of C++17 Fold Expressions. I found that many posts on this topic discuss simple types and ignore how folds may be applicable to more complex types as well. In this post I'm going to describe folding over functions...