C++C++11C++14C++17C++20Learn C++Syntax

What Is A Data Race In Multi-threading C++ Apps And How To Avoid It

In modern programming, if you are developing multithreaded applications, data races are a common problem in threads. Data races occur when multiple tasks or threads access a shared resource without sufficient protection, leading to undefined or unpredictable behavior on runtime. You can imagine two or more task threads in cores trying to reach the same data in a race. In this post, we explain…
Read more
C++C++11C++14C++17Learn C++

What Are Atomic Add And Sub Operations In C++?

The concurrency support library in modern C++ is designed to solve problems in multi-thread operations. Since the C++11 standard, this library includes built-in support for threads (std::thread) with atomic operations (std::atomic). In this post, we explain two atomic operations that can be used with std::atomic types, we explain what are atomic addition and subtraction operations. What is…
Read more
C++C++11C++14C++17Learn C++

What Is A Function Object Functor In C++?

In modern C++ programming we can use many different ways to call functions. One of the features from C11 is functor, an early function object in C++. The functor function objects are callable objects. A functor or function object is any object for which the function call operator is defined. Let’s learn what a functor is and how we can use a functor in C++. What is a functor in…
Read more
C++C++11C++14C++17C++20Learn C++Syntax

How To Use Lambda Expression With std::thread In C++?

Lambda Expressions allow users to write an inline expression that can be used for short snippets of code that are not going to be reused and don’t require naming in your C++ app. The lambda expressions construct is introduced in C++ 11 and further developed in the C++17 and C++20 standards. In modern C++ development, they are very useful and can be used with std::thread in multi-thread…
Read more