September 2018

Stack Factory Puzzle -- Alex Marmer

When instances of classes derived from the same class need to be created based on certain conditions, they are created on the heap. The puzzle is about how to do it on the stack.

Stack Factory Puzzle

By Alex Marmer

 

CppCon 2017: Boost Your Program’s Health by Adding Fibers to your Coroutine

Have you registered for CppCon 2018 in September? Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2017 for you to enjoy. Here is today’s feature:

Boost Your Program’s Health by Adding Fibers to your Coroutine

by David Sackstein

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This session is intended to help the advanced programmer to understand what coroutines and fibers are, what problems they solve and how they should be applied in practice.
The session begins with an overview of these concepts, comparing them with threads, and demonstrating how they are exposed by the Boost libraries.
Apart from being clean and succinct as Boost libraries typically are, the authors of these libraries have gone to great lengths to ensure that fibers and coroutines expose a programming model consistent with that of threads. This will make them seem very familiar.
During the session I will demonstrate how fibers and coroutines can be used together with the powerful Boost.Asio library to solve some commonly occurring problems.
To conclude, I will provide some practical tips and guidelines for those who are adding fibers and coroutines to their programming diet.

Mathematics behind Comparison #4: Three-Way Comparison--Jonathan Müller

Everything you need to know!

Mathematics behind Comparison #4: Three-Way Comparison

by Jonathan Müller

From the article:

In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other. This predicate must “induce a strict total ordering on the equivalence classes” according to cppreference. Wait, what?

The upcoming C++ spaceship operator implements a three-way comparison, i.e. it is a single function that can return the results of <, == and > combined. But related to it are terms like “strong equality” and “weak ordering” which are somewhat confusing if you don’t have the mathematical background.

So let’s untangle it: This series will explain both the mathematics behind equality and ordering, as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.

Now that we’ve covered both equivalence and ordering relations we can finally talk about the spaceship operator and three-way comparisons...

Quick Q: How to track newer C++ std documents of given topic?

Quick A: Use wg21.link

Recently on SO:

How to track newer C++ std documents of given topic?

For the newer proposals (ones that start with the letter P) you can use wg21.link redirect service to obtain the latest document:

wg21.link - WG21 redirect service.

Usage:
wg21.link/nXXXX
wg21.link/pXXXX
wg21.link/pXXXXrX Get paper.

wg21.link/standard
Get working draft.

wg21.link/cwgXXX
wg21.link/ewgXXX
wg21.link/lwgXXX
wg21.link/lewgXXX
wg21.link/fsXXX
wg21.link/editXXX
Get issue.

wg21.link/index.json
wg21.link/index.ndjson
wg21.link/index.txt
wg21.link/specref.json
Get everything.

wg21.link/
Get usage.

For example for P0476: Bit-casting object representations if we use wg21.link/P0476 we obtain the latest version which is P0476R2.

In my answer to How does the standards committee indicate the status of a paper under consideration? I go into more details of the WG21 site and what documents you can find there.

Use the everything link for Pre P proposals
If we use the wg21 redirect service Get Everything link we can do a text search for the paper title. So for your example Improvements to std::future<T> and Related APIs we can see the last document is N3857:

"N3857": {
"type": "paper",
"title": "Improvements to std::future and Related APIs",
"subgroup": "Concurrency",
"author": "N. Gustafsson, A. Laksberg, H. Sutter, S. Mithani",
"long_link": "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3857.pdf",
"link": "https://wg21.link/n3857",
"source": "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/",
"date": "2014-01-16"
},

CppCast Episode 166: CppCon Poster Program and Interface Design with Bob Steagall

Episode 166 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Bob Steagall to discuss his history with C++, the CppCon poster program and his upcoming talks.

CppCast Episode 166: CppCon Poster Program and Interface Design with Bob Steagall

by Rob Irving and Jason Turner

About the interviewee:

Bob is a Principal Engineer with GliaCell Technologies. He's been working almost exclusively in C++ since discovering the second edition of The C++ Programming Language in a college bookstore in 1992. The majority of his career was spent in medical imaging, where he led teams building applications for functional MRI and CT-based cardiac visualization. After a brief detour through the worlds of DNS and analytics, he's now working in the area of distributed stream processing. Bob is a relatively new member of the C++ Standardization Committee, and launched a blog earlier this year to write about C++ and topics related to software engineering. He holds BS and MS degrees in Physics, is an avid cyclist, and lives in fear of his wife's cats.

CppCon 2017: Type Punning in C++17: Avoiding Pun-defined Behavior--Scott Schurr

Have you registered for CppCon 2018 in September? Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2017 for you to enjoy. Here is today’s feature:

Type Punning in C++17: Avoiding Pun-defined Behavior

by Scott Schurr

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Type punning, treating a type as though it is a different type, has a long and sordid history in C and C++. But, as much as we'd like to deny its existence, it plays an important role in efficient low-level code. If you've ever written a program that examines the individual bits of a pointer or of a floating point number, then you've done type punning.

Given its long legacy, some of the techniques for type punning that were appropriate, even encouraged, earlier in history now live in the realm of undefined behavior. We'll identify which techniques are now proscribed and postulate why. We'll also explore ways to do type punning in C++17 that sidestep undefined behavior and are hopefully as efficient as the older techniques.

In this session we will look at:
o Common (and some uncommon) motivations for type punning.
o Techniques for type punning, both good and bad, all ugly.
o Related topics (like type conversions and std::launder()) with an eye toward unspecified and undefined behavior.

Metashell 4.0.0 is available

Metashell provides a compile-time debugger for debugging template instantiations and macro usage.

Metashell 4.0.0 is available

From the website:

Some of the major new features in 4.0.0:

  • The template debugger supports the Templight patch already merged into Clang (7.0.0), therefore it does not require custom Clang builds.
  • Preprocessor shell support for GCC, MSVC and Boost.Wave
  • PDB, the preprocessor debugger (similar to MDB, the template debugger)
  • Using different configs in Metashell (for testing the same templates/macros with different compilers)

The full list of changes can be found here.

An online demo can be found at http://metashell.org/about/demo/

Installers can be downloaded from http://metashell.org/getting_metashell/installers#version-400

Free C++ Course

Free C++ course starting 18th September 2018.

Free C++ Cour​se

About the course:

This is free course, aimed at beginners and intermediate users. Our syllabus is based on Programming: Principles and Practice Using C++, 2nd Edition.

Who can benefit from this course:

  1. People who have no experience with coding
  2. People that come from different languages such as Java, Python, C# etc
  3. Developers that would like to refresh their C++ knowledge

Location:

Please check our website for up to date details www.CPPLondonUni.com

London and Online

London - CodeNode 10 South Pl, London EC2M 7EB

Online - https://goo.gl/BqMCgj (Please RSVP on our host website https:://skillsmatter.com)

When:

Every Tuesday lecture

London - from 18:15 GMT

Online - from 18:30 GMT or soon after

Every Thursday workshop

London - from 18:15 GMT