September 2019

CppCon 2019: Applied WebAssembly: Compiling and Running C++ in Your Web Browser--Ben Smith

The first videos are becoming available.

Applied WebAssembly: Compiling and Running C++ in Your Web Browser

by Ben Smith

From the video:

WebAssembly is a new technology in all modern browsers designed to let you run high-performance code. Maybe you've heard of WebAssembly before, read an article or two, or even tried to use it with your software project. Since WebAssembly is a low-level language, it's easy to get bogged down in the technical details, and leave without knowing whether WebAssembly will be useful for you. In this talk, I'll take a top-down approach, showing a real problem and how WebAssembly can help.

From August to December this year, I'll be teaching C++ to students at Morehouse College. Having a tool like Compiler Explorer is invaluable as a teaching aid, since it allows the students to immediately see C++ compilation results, on any device that has a web browser. But Compiler Explorer and tools like it require a server to do compilation, so they're hard to use offline. With WebAssembly, we can run the compiler client-side, in the browser, no server required.

First, I'll show how I ported the clang compiler and linker to WebAssembly. Since Clang 8 supports WebAssembly as a compilation target, we can even run the resulting executable sandboxed in the browser. Next, we'll dive into how Clang compiles C++ constructs into WebAssembly. Finally, we'll look at some of the new WebAssembly features in development.

C++17 In Detail - Available in Print!

Another book available in Print that describes C++17 features!

See the article that shows more about this release:

C++17 In Detail - Print Version!

by Bartlomiej Filipek

About the book:

C++17 is a major update to the language and brings many exciting additions and improvements that will change your pre for the better. This book shows you all of the significant changes in the new Standard.

I spent hundreds of hours investigating how the new features work to ensure this book is helpful and practical. It will not only save you time but will guide you through lots of nuances of the language and the Standard Library.

If you have experience with C++11/14 and you want to advance to the latest C++ Standard, then pick up the book and start reading.


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)

/ \ 
B   C 
\ / 

And not: (What happens without virtual inheritance)

A   A 
|   |
B   C 
\ / 

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. 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: 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...