C++20 is coming soon, with a number of cool features, one of which is the ranges library. In this article, I aim to demonstrate the power behind the elegant syntax it brings.
Functional Programming (hereinafter FP) is one of the programming paradigms C++…
Functional programming is a programming paradigm, unfortunately, a not so popular one. Many of you (assuming you’re anywhere near C++) probably have heard that C++ is a multiparadigm language, but do you really feel that? If not (or you didn’t even know that), I’m really glad you’re here.
OOP (Object Oriented Programming) is yet another programming paradigm, a very popular one. It’s not so popular for no reason: it has lots of advantages, most of which are just perfect from the business perspective. As a result, it’s become so popular and demanding that most C++ language courses will jump to…
C++11/14 was a major update over the previous C++98. This book sheds light on it in a classic, Scott Meyers way. Amazon link to the book.
The first chapter, Deducing Types, consists of four items that prepare a good ground for understanding the 2nd and 5th chapters about auto
and move semantics, respectively.
The second chapter goes deeper into the auto, suggesting when to and not to use it. …
If you’re an experienced C++ programmer, you’ve most probably heard the name Scott Meyers, moreover, you’ve thanked him for his brilliant books. The “Effective STL” is one of them.
If you’re new to the C++ and you were trying to understand whether this book (or STL in general) is worth checking out, stay tuned!
The Standard Template Library (STL) is the language built-in library for C++. It consists of perfectly designed and implemented utilities. I’ll go ahead and say that it’s more than a library: it’s a whole world with its philosophy and rules, a…
C++20 is coming with a bunch of cool new features, one of which I’ll shortly cover here: the std::jthread
.
The implementation of this std::jthread
is based on the already existing std::thread
. It’s basically a wrapper that brings two new features to the threads: they are cooperatively interruptible and join by default. Before going deeper into these two terms, note that the std::jthread
object wraps anstd::thread
as a member, providing the very same public functions, which simply transfer down the calls. This enables us to change any std::thread
into std::jthread
, knowing for sure that it’ll work as before.
The name suggests…
Once a friend of mine shared with me a logic question he was asked at an interview. It turned out to be very interesting, thus I want to share it with you, as well as our jurney to its solution.
The problem statement goes like this:
For a given natural N count the number of N sized binary sequences with no consecutive ones.
Let’s look at the example of N=3. There are 8 binary sequences of length 3 in total:
000 OK
001 OK
010 OK
011 VIOLATING
100 OK
101 OK
110 VIOLATING
111 VIOLATING
… 3 of which…
Bugs are our enemies. Most of them are stupid and easy-to-find: an exception, a segmentation fault, an obvious memory overhead, etc. They show themselves quite soon. But there are some, that are very well hidden, like silent killers, harming unnoticeably. These are the worst ones: they’re hard to find, even harder to notice. Usually, they are noticed and fixed so late, that their damage is irreversible.
Let’s take a look at the following example.
This article contains gist embeds, which might not be shown in the mobile app.
Consider such a situation: you have Employee
objects and you want to…
Historically, multithreading was a big pain for C++ programmers, because it wasn’t supported by the language for a long time. It was not until C++11 that it became a standard. And now “multithreading” is easier than ever. Or is it?
The short answer is: “Absolutely yes, but only IF you use it correctly”. C++ tried very hard to keep its multithreading interface as minimalistic and clean as possible. To prove my point, let’s see what does the std::thread
class look like. In some other languages the Thread
classes are pretty big, have lot’s of member functions, which make it not…