Shahar's C++ posts:

Longest C++ Variable Declaration

Here’s a challenge: what’s the longest variable declaration you can come up with?

Compiling Clang from Scratch

In this post I’ll show how easy it is to build clang from scratch on Linux, and how to use it both directly and with CMake.

Move Semantics

Move Semantics are a C++11 feature which complements C++98’s RVO; Think of them as user-defined RVO-like optimization. While originally designed to only allow optimizations, one can also utilize move semantics to limit APIs. This is how std::unique_ptr is able to be a move-only type, allowing it to enforce single ownership (more about std::unique_ptr here).

Return Value Optimization

Return Value Optimization (RVO), Named RVO (NRVO) and Copy-Elision are in C++ since C++98. In this post I will explain what these concepts mean and how they help improve runtime performance.

Using libclang to Parse C++ (aka libclang 101)

In this post I’ll provide a quick tutorial for using libclang. I started playing around with libclang while implementing Reflang – an open source reflection framework for C++. Then I came to appreciate the amazing work done by its developers.

Exploring std::shared_ptr

Today we’ll talk about C++’s built-in smart pointer std::shared_ptr. If you have not yet read my previous post about std::unique_ptr I would highly recommend doing so before continuing.

Exploring std::unique_ptr

Today we’ll talk about C++’s built-in smart pointer std::unique_ptr, which is an extremely powerful, simple & common tool.

Exploring std::string

Every C++ developer knows that std::string represents a sequence of characters in memory. It manages its own memory, and is very intuitive to use. Today we’ll explore std::string as defined by the C++ Standard, and also by looking at 4 major implementations.

Template SFINAE & type-traits

Today’s post is about template SFINAE & type-traits - cool C++ features with great compile-time power.

UserData class

Many libraries provide their users with a way to add user-defined content to the library’s objects. This is especially true for libraries in the graphics domain. Examples:

Naive std::function implementation

After exploring std::function in a previous post, I thought that it might be a good practice to implement a simple (and partial) std::function. It turned out to be much less code than I anticipated. I hope you’ll like it.

C++ vtables - Part 4 - Compiler-Generated Code

So far in this mini-series we learned how the vtables and typeinfo records are placed in our binaries and how the compiler uses them. Now we’ll understand some of the work the compiler does for us automatically.

C++ vtables - Part 3 - Virtual Inheritance

In Part 1 and Part 2 of this series we talked about how vtables work in the simplest cases, and then in multiple inheritance. Virtual inheritance complicates things even further.

C++ vtables - Part 2 - Multiple Inheritance

The world of single-parent inheritance hierarchies is simpler for the compiler. As we saw in Part 1, each child class extends its parent vtable by appending entries for each new virtual method.

In this post we will cover multiple inheritance, which complicates things even when only inheriting from pure-interfaces.

C++ vtables - Part 1 - Basics

In this mini post-series we’ll explore how clang implements vtables & RTTI. In this part we’ll start with some basic classes and later on cover multiple inheritance and virtual inheritance.

Please note that this mini-series will include some digging into the binary generated for our different pieces of code via gdb. This is somewhat low-level(ish), but I’ll do all the heavy lifting for you. I don’t believe many future posts will be this low-level.

Under the hood of lambdas and std::function

In this post we’ll explore how lambdas behave in different aspects. Then we’ll look into std::function and how it works.