Quick Q: How does virtual inheritance solve the “diamond” (multiple inheritance) ambiguity?

Quick A: by making sure only one instance of each parent class is created.

Recently on SO:

How does virtual inheritance solve the “diamond” (multiple inheritance) ambiguity?

You want: (Achievable with virtual inheritance)

  A 
/ \ 
B   C 
\ / 
  D

And not: (What happens without virtual inheritance)

A   A 
|   |
B   C 
\ / 
  D

Virtual inheritance means that there will be only 1 instance of the base A class not 2.

Your type D would have 2 vtable pointers (you can see them in the first diagram), one for B and one for C who virtually inherit A. D's object size is increased because it stores 2 pointers now; however there is only one A now.

So B::A and C::A are the same and so there can be no ambiguous calls from D. If you don't use virtual inheritance you have the second diagram above. And any call to a member of A then becomes ambiguous and you need to specify which path you want to take.

CppCon 2019: Speed Is Found In The Minds of People--Andrei Alexandrescu

The first videos are arriving!

Speed Is Found In The Minds of People

by Andrei Alexandrescu

From the video:

In all likelihood, sorting is one of the most researched classes of algorithms. It is a fundamental task in Computer Science, both on its own and as a step in other algorithms. Efficient algorithms for sorting and searching are now taught in core undergraduate classes. Are they at their best, or is there more blood to squeeze from that stone? This talk will explore a few less known – but more allegro! – variants of classic sorting algorithms. And as they say, the road matters more than the destination. Along the way, we'll encounter many wondrous surprises and we'll learn how to cope with the puzzling behavior of modern complex architectures.

CopperSpice: Any Optional

New video on the CopperSpice YouTube Channel:

Any Optional

by Barbara Geller and Ansel Sermersheim

About the video:

In this video, we discuss the std::any and std::optional classes, what they are, and how you might use them to write type safe code. We also talk about type safety in general, and how it relates to C++.

Please take a look and remember to subscribe!

New new() - The C++17's Alignment Parameter for the operator new() -- Bartlomiej Filipek

C++17's new and handy new operator that supports overaligned objects!

New new() - The C++17's Alignment Parameter for Operator new()

by Bartlomiej Filipek

From the article:

The whole deal about the new functionality is that you can forgot about the limitation of over-aligned data. It lets you write regular modern C++ code without worrying about specialized allocators or raw memory handling functions like std::aligned_alloc() or _aligned_malloc().

Open Sourcing MSVC's STL

Just announced at CppCon:

Open Sourcing MSVC's STL

From the announcement:

Today at CppCon 2019, we (the MSVC team) announced that we’re releasing our implementation of the C++ Standard Library (also known as the STL) as open source.

https://github.com/microsoft/STL is our new repository, containing all of our product source code, a new CMake build system, and a README with more information. As it explains, we’re still working on migrating to GitHub. While you can clone and build the code right now, there are several things we need to do (like adding our test suites) before we can begin reviewing pull requests.

Q&A

Q: Why are you doing this?

A: There are several reasons. ...

Back to Basics at CppCon 2019

It started!

Back to Basics at CppCon 2019

by Arthur O’Dwyer

From the article:

Tomorrow I’ll be flying out to Denver, Colorado, for CppCon 2019. This will be my busiest CppCon yet! Besides giving my “STL From Scratch” weekend course for the third year in a row, this year I’m also the chair of CppCon’s new “Back to Basics” track...

Trip Report: ISO C++ Meeting Cologne (2019) -- Matthias Gehre

Matthias Gehre’s trip report of the ISO C++ committee meeting in Cologne in 2019.

Trip Report: ISO C++ Meeting Cologne (2019)

by Matthias Gehre

From the trip report:

This is my trip report of the ISO C++ Meeting in Cologne – my first ISO C++ Meeting.

I will not so much focus on the big features that were approved for C++20 (there are better reports),

but more describe my personal experience. The report also contains discussions on

many lesser-known papers.