May 2018

std::accumulate vs. std::reduce--Simon Brand

Old vs new.

std::accumulate vs. std::reduce

by Simon Brand

From the article:

std::accumulate has been a part of the standard library since C++98. It provides a way to fold a binary operation (such as addition) over an iterator range, resulting in a single value. std::reduce was added in C++17 and looks remarkably similar. This post will explain the difference between the two and when to use one or the other...

How to Make SFINAE Pretty – Part 2: the Hidden Beauty of SFINAE--Jonathan Boccara

The next part.

How to Make SFINAE Pretty – Part 2: the Hidden Beauty of SFINAE

by Jonathan Boccara

From the article:

As we’ve seen in How to Make SFINAE Pretty – Part 1: What SFINAE Brings to Code, SFINAE in code is as pretty as a windmill in a field. That is, not very pretty.

But like a windmill, it’s useful. SFINAE helps deactivate a piece of template code depending on a condition, and that can be very convenient...

How to Make SFINAE Pretty – Part 1: What SFINAE Brings to Code

New series!

How to Make SFINAE Pretty – Part 1: What SFINAE Brings to Code

by Jonathan Boccara

From the article:

SFINAE is a bit like a windmill. It sits as a wart in the middle of an interface, BUT it’s useful to create elaborate static polymorphism, in particular before C++17 and if constexpr, and even in some use cases in C++17.

I thought we had to live with this tradeoff, until I watched a talk from Stephen Dewhurst at CppCon. In this inspring talk, Stephen shows how to turn SFINAE around to make it very expressive in an interface. Watching this talk changed my way of coding template interfaces...

Default-constructibility is overrated--Arthur O’Dwyer

What do you think?

Default-constructibility is overrated

by Arthur O’Dwyer

From the article:

The Ranges Technical Specification includes very many concept definitions (based on the Concepts TS), including for example Integral and Predicate. It also provides a concept named Regular which implements a variation on the “Regular” concept described by Alexander Stepanov in his paper '’Fundamentals of Generic Programming’’ (1998)...

Quick Q: typedef pointer const weirdness

Quick A: Don't hide pointers in typedefs.

Recently on SO:

typedef pointer const weirdness

Note that

typedef int* intptr;
const intptr x;

is not the same as:

const int* x;

intptr is pointer to int. const intptr is constant pointer to int, not pointer to constant int.

so, after a typedef pointer, i can't make it const to the content anymore?

There are some ugly ways, such as gcc's typeof macro:

typedef int* intptr;
intptr dummy;
const typeof(*dummy) *x;

but, as you see, it's pointless if you know the type behind intptr.

CppCast Episode 150: Freestanding Proposal with Ben Craig

Episode 150 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Ben Craig to discuss his proposal for a freestanding C++ Library.

CppCast Episode 150: Freestanding Proposal with Ben Craig

by Rob Irving and Jason Turner

About the interviewee:

Ben is a Principal Software Engineer at National Instruments, primarily developing device drivers for various operating systems (Windows, Linux, Mac, OpenRTOS, vxWorks, ETS Pharlap), and occasionally tinkering with the firmware side of things. Ben is an occasional contributor to libc++ and Apache Thrift.