Articles & Books

New C++ experimental feature: The tadpole operators--Raymond Chen

You should read about this amazing new feature:

New C++ experimental feature: The tadpole operators

by Raymond Chen

From the article:

How often have you had to write code like this:

x = (y + 1) % 10;
x = (y + 1) * (z - 1);
x = (wcslen(s) + 1) * sizeof(wchar_t);

Since the + and - operators have such low precedence, you end up having to parenthesize them a lot, which can lead to heavily nested code that is hard to read...

Once you have been thoroughly amazed, you should also read this article:

The tadpole operators explained

Cling Aims to Provide a High-performance C++ REPL--Sergio De Simone

Read about a REPL allowing to test things rapidly in C++:

Cling Aims to Provide a High-performance C++ REPL

by Sergio De Simone

From the article:

Cling is an interactive C++ interpreter that is built on top of LLVM and Clang and promises to provide a leap in productivity by going beyond the usual code-compile-run-debug C++ workflow...

Other useful materials:

C++17 Fold Expressions--Baptiste Wicht

You should read that if you want to know more about this exciting future feature of C++:

C++17 Fold Expressions

by Baptiste Wicht

From the article:

C++11 introduced variadic template to the languages. This new feature allows to write template functions and classes taking an arbitrary number of template parameters. This a feature I really like and I already used it quite a lot in my different libraries. Here is a very simple example computing the sum of the parameters:

// Good with variadics
auto old_sum(){
    return 0;
}

template<typename T1, typename... T>
auto old_sum(T1 s, T... ts){
    return s + old_sum(ts...);;
} 

// Better with fold expressions
template<typename... T>
auto fold_sum_1(T... s){
    return (... + s);
}x

Using Monads in C++ to Solve Constraints: 4. Refactoring--Bartosz Milewski

Time for refactoring functional code! Bartosz Milewski concludes his intriguing journey about the application of Monads in C++.

Using Monads in C++ to Solve Constraints: 4. Refactoring

by Bartosz Milewski

From the article:

In this installment I’d like to talk about something that a lot of functional programmers swear by: Functional programs are amazingly easy to factorize.

Acting In C++--Anthony DaSilva Jr

You will find here an article about:

Acting In C++

by Anthony DaSilva Jr

From the article:

Because they’re a perfect fit for mega-core processors and they’re safer and more enjoyable to program than raw, multi-threaded, systems, I’ve been a fan of Actor-based concurrent systems ever since I experimented with Erlang and Akka (via its Java API). Thus, as a C++ programmer, I was excited to discover the “C++ Actor Framework” (CAF). Like the Akka toolkit/runtime, the CAF is based on the design of the longest living, proven, production-ready, pragmatic, actor-based, language that I know of – the venerable Erlang programming language...

C++ Best Practices: A Forkable Standards Document - Jason Turner

A forkable coding standards and best practices document for C++.

C++ Best Practices

by Jason Turner

From the book

It (C++ Best Practices) compliments books such as Effective C++ (Meyers) and C++ Coding Standards (Alexandrescu, Sutter). We fill in some of the lower level details that they don't discuss and provide specific stylistic recommendations while also discussing how to ensure overall code quality.

...

This document is based on my personal experiences. You are not supposed to agree with it 100%. It exists as a book on github so that you can fork it for your own uses or submit back proposed changes for everyone to share.

 

Using Monads in C++ to Solve Constraints: 3. The Tale of Two Monads—Bartosz Milewski

Bartosz Milewski continues to explain how to use Monads in C++.

Using Monads in C++ to Solve Constraints: 3. The Tale of Two Monads

by Bartosz Milewski

From the article:

The functional solution to our problem involves the combination of the list monad and the state monad. Mashing two monads together is not trivial — in Haskell this is done using monad transformers — but here I’ll show you how to do it manually...

Handling short codes (part I)--Andrzej Krzemieński

First part of a discussion about designing a type storing character strings of length N (known at compile-time and sufficiently small).

Handling short codes - part I

by Andrzej Krzemieński

From the article:

In my work, we often deal with codes [...] The initial choice was to represent them in programs by type std::string, a general-purpose type for storing sequences of characters. But, as with any general-purpose tools, they fail to take into account the particular usage cases which often offer room for improvements [...] The following is an attempt at the design of a type that would take advantage of the information that we are only storing character strings of length N, where N is sufficiently small (say, no longer than 8)...

Using Monads in C++ to Solve Constraints: 2. The State Monad—Bartosz Milewski

Bartosz Milewski continues to explain how to use Monads in C++.

Using Monads in C++ to Solve Constraints: 2. The State Monad

by Bartosz Milewski

From the article:

We all like making plans, but they are often contingent on the state of our finances. Such plans can be described by functions. In general, a financial plan is a function that takes cash and returns the result paired with the new value of cash. It can be described generically using a template...