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.

Prepping Yourself to Conceptify Algorithms -- Christopher Di Bella

In this article, we explore what concepts are, where they are useful, and how they are different to things that exist in vanilla C++17.

Prepping Yourself to Conceptify Algorithms

by Christopher Di Bella

From the article:

A very quick summary of this document is that constraints are requirements imposed on syntax, axioms are requirements imposed on semantics, and concepts are both constraints and axioms together.

...

Let’s build the EqualityComparableWith concept from the Ranges TS, from the ground up.

C++ Weekly Episode 115: Compile Time ARM Emulator—Jason Turner

Episode 115 of C++ Weekly.

Compile Time ARM Emulator

by Jason Turner

About the show:

This episode of C++ Weekly demonstrates a compile time ARM CPU emulator using C++17 constexpr. No special tricks were necessary to accomplish this feat, merely following a rule of "constexpr everything that is reasonable." The code is portable and currently compiles with GCC and Clang in about 2 seconds for simple compile-time test cases.

Using C++17 std::optional -- Bartlomiej Filipek

See how and when std::optional from C++17 is useful:<img alt="" data-cke-saved-src="https://dl.dropboxusercontent.com/s/nv9s71vz8kq8pq3/stdoptusing.png?dl=0" src="https://dl.dropboxusercontent.com/s/nv9s71vz8kq8pq3/stdoptusing.png?dl=0" 400px;="" height:="" 128px;="" float:="" right;"="" style="height: 74px; width: 230px; float: right;">

Using C++17 std::optional

by Bartlomiej Filipek

From the article:

By adding the boolean flag to other types, you can achieve a thing called “nullable types”. As mentioned, the flag is used to indicate whether the value is available or not. Such wrapper represents an object that might be empty in an expressive way (so not via comments smile)