Future Ruminations -- Sean Parent

This post is a lengthy answer to a question from Alisdair Meredith via Twitter

Future Ruminations

by Sean Parent

From the article:

The question is regarding the numerous proposals for a better future class template for C++, including the proposal from Felix Petriconi, David Sankel, and myself.

It is a valid question for any endeavor. To answer it, we need to define what we mean by a future so we can place bounds on the solution. We also need to understand the problems that a future is trying to solve, so we can determine if a future is, in fact, a useful construct for solving those problems.

The proposal started with me trying to solve a fairly concrete problem; how to take a large, heavily threaded application, and make it run in a single threaded environment (specifically, compiled to asm.js with the Emscripten compiler) but also be able to scale to devices with many cores. I found the current standard and boost implementation of futures to be lacking. I open sourced my work on a better solution, and discussed this in my Better Code: Concurrency talk. Felix heard my CppCast interview on the topic, and became the primary contributor to the project.

Playing with C++ Coroutines--Sumant Tambe

An old presentation about coroutines:

Playing with C++ Coroutines

by Sumant Tambe

From the article:

While looking for some old photos, I stumbled upon my own presentation on C++ coroutines, which I never posted online to a broader audience. I presented this material in SF Bay ACCU meetup and at the DC Polyglot meetup in early 2016! Yeah, it's been a while. It's based on much longer blogpost about Asynchronous RPC using modern C++. So without further ado...

It had to be done - Abusing co_await for optionals--redditsoaddicting

The future is not here yet that it's already full of resources!

It had to be done - Abusing co_await for optionals

by redditsoaddicting

From the article:

I finally got around to playing with coroutines in the context of non-future types. I always guessed this could be done. For optionals specifically, the idea is that you do auto x = co_await foo(); and either x is the value in the optional or the function immediately returns an empty optional...

C++ Siberia 2017

cppsiberia.PNGThis year C++ Siberia conference will take place in Tomsk at 25-26 of August. The opening keynote will be given by Ivan Cukic.  The conference will be held at Tomsk State University.

The conference information (Russian language):

C++ Siberia

Tomsk, Siberia, 25-26 August

Check out Siberia this summer!

Confirmed speakers & talks at Meeting C++ 2017

A first list on confirmed speakers and their talks for this years Meeting C++ conference!

Confirmed Speakers & Talks at Meeting C++ 2017

by Jens Weller

From the article:

Last week the decisions for who could speak at Meeting C++ 2017 was made, and the selected candidates were contacted. Here is a little overview on talks and speakers for this years conference. There is a few speakers which haven't reacted yet, hope to share these talks soon too.

C++17 in details: Attributes

Another part of the series on C++17 details.

C++17 in details: Attributes

by Bartlomiej Filipek

From the article:

Previously each compiler could specify its own syntax and list of available attributes, but in modern C++ the committee tried to standardize this: there are some extracted, common parts. Plus each compiler is not blocked to add its own extensions. Maybe at some point, we’ll move away from __attribute or __declspec or #pragma?

Quick Q: How to make my custom type to work with “range-based for loops”?

Quick A: Create member functions begin() and end() returning an iterator.

Recently on SO:

How to make my custom type to work with “range-based for loops”?

The standard has been changed since the question (and most answers) were posted in the resolution of this defect report.

The way to make a for(:) loop work on your type X is now one of two ways:

  • Create member X::begin() and X::end() that return something that acts like an iterator
  • Create a free function begin(X&) and end(X&) that return something that acts like an iterator, in the same namespace as your type X.

And similar for const variations. This will work both on compilers that implement the defect report changes, and compilers that do not.

Quick Q: Initializing a C++11 string with {}

Quick A: It calls the initializer_list constructor that has the same effect in this case.

Recnetly on SO:

Initializing a C++11 string with {}

The {} initialization syntax is known as the uniform initialization syntax, it has a few key differences, but in your code as is they both do the same thing - construct a std::string object from the string literal "Test"

Initializing an object with an assignment is essentially the same as putting the right hand side in parentheses and constructing the object. For example the below two are the same

T obj = a;
T obj(a);

So you should be asking yourself, what is the difference between constructing a string object the following two ways

std::string{"Test"};
std::string("Test");

And the answer is that both the constructions above are the same and call the same constructor for std::string

For more on uniform initialization see https://softwareengineering.stackexchange.com/questions/133688/is-c11-uniform-initialization-a-replacement-for-the-old-style-syntax