advanced

C++ Tricks: Fast RTTI and Dynamic Cast--Samuel Kahn

Only for special cases.

C++ Tricks: Fast RTTI and Dynamic Cast

by Samuel Kahn

From the article:

As introduced in the first post of these series, I will share the first piece of KCL: an implementation of RTTI and Dynamic Cast. The code can be found on GitHub.

If you don’t know what dynamic casting is, then I suggest you read some online resources before diving into this article...

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.

Highlighting the Student and Support Tickets for Meeting C++ 2019

Also available in this year: the programs for students and diversity & support for Meeting C++ 2019

Highlighting the Student and Support Tickets for Meeting C++ 2019

by Jens Weller

From the article:

With the Schedule for Meeting C++ 2019 being complete regarding submitted talks, I want to highlight, that there is an opportunity for folks to attend the conference with a free ticket!

Quick Q: Where and why do I have to put the “template” and “typename” keywords?

Quick A: to help the compiler understand what the programmer wants.

Recently on SO:

Where and why do I have to put the “template” and “typename” keywords?

In order to parse a C++ program, the compiler needs to know whether certain names are types or not. The following example demonstrates that:

t * f;

How should this be parsed? For many languages a compiler doesn't need to know the meaning of a name in order to parse and basically know what action a line of code does...

The Power of Hidden Friends in C++--Anthony Williams

Did you know about them?

The Power of Hidden Friends in C++

by Anthony Williams

From the article:

"Friendship" in C++ is commonly thought of as a means of allowing non-member functions and other classes to access the private data of a class. This might be done to allow symmetric conversions on non-member comparison operators, or allow a factory class exclusive access to the constructor of a class, or any number of things.

However, this is not the only use of friendship in C++, as there is an additional property to declaring a function or function template a friend: the friend function is now available to be found via Argument-Dependent Lookup (ADL). This is what makes operator overloading work with classes in different namespaces...

"Allegro" Means Both Fast and Happy. Coincidence? - Andrei Alexandrescu

The Italian C++ Conference 2019 keynote:

"Allegro" Means Both Fast and Happy. Coincidence?

by Andrei Alexandrescu

About the video:

Sorting and searching. Two fundamental tasks in Computer Science, and definitely among the most studied. 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 algorithms.

Kadane in next-gen C++--Marco Arena

A new interpretation of a classical problem:

Kadane in next-gen C++

by Marco Arena

From the article:

We, programmers, get better results while thinking in patterns. We decompose complex problems in combinations of simpler patterns. However, many problems cannot be solved with known patterns. Here is where creativity kicks in...