Looking at S-Core today feels a bit like walking into a German factory that has just announced a “major transformation initiative.” Before anything actually starts to change, there are: The intention is good, but as my colleague from work pointed out some time ago: “bureaucracy expands to meet the needs…
C++
Thirdparty dependencies with FetchContent
Welcome to the next pikoTutorial ! FetchContent module tries to be the solution to never-ending discussion about the package management in C++ (I wrote a bit about it in one of the articles of Make C++ a better place series). It’s not a package manager by itself, but it integrates…
Folding expressions in C++
Welcome to the next pikoTutorial ! What is a folding expression? Imagine that you have a vector of integers and you need to add some predefined values to it. The obvious choice seems to be just using push_back() function applied a couple of times: This works, but look how much…
Separating builds for different configs with Bazel
Welcome to the next pikoTutorial ! Let’s consider a simple project with the following structure: The main function has 2 compile switches: And we have 2 separate Bazel configurations including these switches: When we build the application with the following command: I can run the application by invoking: But as…
Destruction order vs thread safety in C++
Welcome to the next pikoTutorial ! What’s the problem? Let’s take a look at the simple example below: Let’s quickly sum up what’s going on here and what could be the expected output of such program: To understand why it happens, let’s add a custom deleter to the unique pointer,…
Registering callback using std::function in C++
Welcome to the next pikoTutorial! Imagine you’re building an application that processes some data and once it’s done, the user needs to be notified about the result. Since you don’t want to hard-code the notification logic, it’s better to allow the user to register a custom function that will be…
Calling member function on a nullptr in C++
Welcome to the next pikoTutorial! nullptr and the segmentation fault One of the first things that beginner C++ programmers realize after starting to play around with pointers is that dereferencing a nullptr leads to an immediate program crash caused by the segmentation fault. This leads to a common belief that…
Parameters combinations in GoogleTest
Welcome to the next pikoTutorial! Parameterized unit tests are priceless. They help to test code thoroughly through multiple possible input values, without having to write multiple and almost the same unit tests – if you have a function accepting an enum and output for some of them is the same,…
Custom literals in C++
Welcome to the next pikoTutorial! What are C++ literals? Literals in C++ are constant values directly embedded into the code, such as numbers, characters and strings. They represent fundamental data, making the code more readable and expressive. C++ provides several built-in literals, like integer literals (42), floating-point literals (3.14), and…
Enums vs enum class in C++
Welcome to the next pikoTutorial! When dealing with enumerations in C++, developers have two primary options: traditional enum and enum class. Traditional enums vs enum classes At the first glance, the only difference appears to be in the class keyword: The real difference is however in how both of them…
Functions calling order in unit tests in C++
To ensure a certain order of function calls, GTest provides 2 ways to do that: InSequence and Sequence objects.
5 misconceptions about std::move in C++
Welcome to the next pikoTutorial! std::move moves an object One of the most prevalent misconceptions is that std::move actually moves an object. In reality, std::move does not perform any movement – it casts its argument to an rvalue reference. This enables the compiler to apply move semantics, but std::move itself…
Build & run C++ unit tests with CMake
Welcome to the next pikoTutorial! Building and running a single test file To present the easiest case, we need to assume some folder structure of our project: Here the easiest case means that we have only on library and only one test file for it. Firstly of all, we need…
5 ways of passing unique pointer to a function in C++
std::unique_ptr is one of the most common non-copyable types – types, whose constructor has been explicitly deleted in their implementation.
5 least known STL utilities in C++
Learn about 5 least known yet very useful utilities from STL like std::shared_mutex or std::clamp.
Why implement custom copy constructor in C++?
Nowadays there are many high level languages in which you don’t have to care about how objects are copied around. However, if you want to write in C++, you must understand that copying is a very distinct operation.