Lambda Week: Tricks

We’re on the last day of the lambda week. We have all the essential knowledge, and now we can learn some tricks! The Series This blog post is a part of the series on lambdas: The syntax changes (Tuesday 4th August) Capturing things (Wednesday 5th August) Going generic (Thursday 6th August) Tricks (Friday 5th August)(this post) +[]() Have a closer look:

READ MORE...

Lambda Week: Going Generic

We’re in the third day of the lambda week. So far, you’ve learned basic syntax and how to capture things. Another important aspect is that lambdas can also be used in the “generic” scenarios. This is especially possible since C++14 where we got generic lambdas (auto arguments), and then in C++20, you can even specify a template lambda!

READ MORE...

Lambda Week: Capturing Things

We’re in the second day of the lambda week. Today you’ll learn about the options you have when you want to capture things from the external scope. Local variables, global, static, variadic packs, this pointer… what’s possible and what’s not? The Series This blog post is a part of the series on lambdas:

READ MORE...

Lambda Week: Syntax changes, C++11 to C++20

Let’s start the week with Lambda Expressions. The plan is to have a set of concise articles presenting core elements of lambda expressions. Today you can see how the syntax has evolved starting since C++11 and what are the latest changes in C++20. The Series This blog post is a part of the series on lambdas:

READ MORE...

Non Static Data Members Initialization

With modern C++ and with each revision of the standard we get more comfortable way to initialise fields of a class: both static and non-static: there’s non-static data member initialisation (from C++11) and also inline variables (for static members since C++17). In this blog post, you’ll learn how to use the syntax and how it changed over the years from C++11, through C++14, C++17 until C++20.

READ MORE...

Lambdas: From C++11 to C++20, Part 1

Lambda expressions are one of the most powerful additions to C++11, and they continue to evolve with each new C++ language standard. In this article, we’ll go through history and see the evolution of this crucial part of modern C++. The second part is available: Lambdas: From C++11 to C++20, Part 2

READ MORE...

C++17 in details: Attributes

“C++ Attributes… what?” There were almost 40% votes like that in my recent Twitter survey. Maybe It would be good to introduce that little-known feature? There’s even a good occasion, as in C++17 we’ll get even more useful stuff connected with attributes. Interested? Intro Have you ever used __declspec, __attribute or #pragma directives in your code?

READ MORE...

Wrapping Resource Handles in Smart Pointers

Some time ago I covered how to use custom deleters with smart pointers. The basic idea is to specify a dedicated method that will be called when a pointer is released. One logical application of custom deleters might be resource handles like files or the WinApi HANDLE type. Let’s see how can we implement such thing.

READ MORE...