Open in app

Sign In

Write

Sign In

CMP
CMP

28 Followers

Home

About

Sep 15

const vs constexpr in C++

Both const and constexpr are keywords used to specify that a value cannot be modified, but they have some differences in functionality and use cases. What is const? const is a fundamental keyword in C++ used for defining constant variables, meaning the value of the variable cannot change. …

Cpp

4 min read

Cpp

4 min read


Sep 8

Endianness in C++20

A portable way to check for system endianness in C++ — Endianness Basics The endianness of a system refers to the order in which bytes are stored in memory or transmitted over a network. Big-Endian systems store the Most Significant Byte (MSB) at the lowest memory address. This is used in various network protocols to send data over a network, also…

Cpp

2 min read

Cpp

2 min read


Aug 28

Introduction to the C++20 spaceship operator

C++20 introduced the three-way comparison operator, also known as the “spaceship operator” due to its appearance: <=>. The purpose is to streamline the process of comparing objects. The Basics Below is a simple example that uses this new spaceship operator: #include <compare> int main() { int a = 1…

Cpp

7 min read

Cpp

7 min read


Aug 21

Mastering memory efficiency with std::span

A useful C++20 tool for providing a non-owning view of contiguous memory — Before diving into the usage of std::span, it is important to understand the concept of ownership of resources. When a container such as a std::vector is created, the container has ownership of the memory used to store data inside of it, meaning that it is the responsibility of the container…

Cplusplus

6 min read

Cplusplus

6 min read


Aug 1

Modern C++ memory allocation

Memory allocation is an important concept for systems programmers to understand, especially when working in environments where resources are limited. This article will go over the differences between the different types of memory allocation and the best practices in modern C++. Static vs. Dynamic vs. Automatic Memory Allocation When learning…

Cpp

8 min read

Cpp

8 min read


Jun 20

C++20 Concurrency: std::barrier

A reusable alternative to std::latch — I previously wrote about using std::latch to synchronize multiple threads. While that is a great mechanism for simple one-time synchronization scenarios where multiple threads need to meet at a synchronization point before continuing execution, it is less flexible than the other new C++20 concurrency primitive: std::barrier. What is std::barrier? Like…

Cpp

2 min read

Cpp

2 min read


Jun 16

std::lock_guard vs std::unique_lock vs std::scoped_lock

So many C++ locking mechanisms… which one should you choose? — If you’ve ever written concurrent code in C++ or any other language, then you know how difficult it can be to properly protect access to resources without causing data races or deadlocks. C++11 and C++17 have introduced several great locking mechanisms to help programmers write concurrent code, but which one(s)…

Cpp

4 min read

Cpp

4 min read


Jun 14

C++20 Concurrency: std::latch

A convenient way to coordinate concurrent tasks — When running multiple tasks in concurrent threads, you may wish to ensure that each thread has reached a certain point in its execution before proceeding further. Prior to C++20, you would need some sort of shared atomic counter to achieve this: std::atomic<int> counter(0); // Shared atomic counter void worker() {…

Cplusplus

2 min read

Cplusplus

2 min read


Jun 6

C++20 Concurrency: std::jthread

This new threading mechanism will greatly improve your existing code — C++20 has introduced several new features to help developers write simpler, safer, and more efficient concurrent code. One of these features is the std::jthread mechanism. What is it? std::jthread is a new concurrency mechanism in C++20 that represents a joinable thread (hence the “j” in “jthread”) with automatic cleanup. std::jthread…

Cpp

2 min read

Cpp

2 min read


Jun 6

uint32_t vs unsigned int — Which one is better?

If you’re not a systems programmer then it probably doesn’t matter — Most C++ programmers are aware of the basic data types and their unsigned counterparts — int vs unsigned int, long vs unsigned long, etc. However, many are unaware of the various fixed-width integers defined in the <cstdint> header, such as uint8_t, uint16_t, uint32_t, and uint64_t. …

Cpp

2 min read

Cpp

2 min read

CMP

CMP

28 Followers
Following
  • Šimon Tóth

    Šimon Tóth

  • Andrey Karpov

    Andrey Karpov

  • Alexey Medvecky

    Alexey Medvecky

  • Elysium Celeste

    Elysium Celeste

  • Honusz

    Honusz

See all (21)

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams