Implementing Spinlocks with C++11 atomic_flag
Understanding atomic_flag
The atomic_flag is the simplest atomic boolean type in C++11's <atomic> header, supporting only two operations: test_and_set and clear.
Constructor and Initialization
atomic_flag() noexcept = default;
atomic_flag(const atomic_flag&) = delete;
atomic_flag has only a default constructor. Copy construction is d ...
Posted on Wed, 09 Sep 2026 16:07:04 +0000 by RestlessThoughts
Understanding Smart Pointers in C++
Smart pointers are a powerful feature introduced in C++11 that automate memory management, significantly reducing the complexity of manual resource handling. The C++ standard library provides three main types of smart pointers: std::unique_ptr, std::shared_ptr, and std::weak_ptr. std::unique_ptr implements exclusive ownership, ensuring only one ...
Posted on Sat, 29 Aug 2026 16:15:12 +0000 by kdoggfunkstah
Understanding Lambda Expressions in C++11
Lambda expressions were introduced in C++11 to simplify the use of function objects, especially when passing custom logic to standard algorithms like std::sort.
Motivation for Lambda Expressions
In C++98, defining custom comparison logic required creating a separate functor class:
struct Product {
std::string name;
double price;
int ...
Posted on Sun, 02 Aug 2026 17:01:16 +0000 by $SuperString
Understanding C++ Smart Pointers: unique_ptr, shared_ptr, and weak_ptr
Smart pointers, introduced in C++11, provide automatic memory management by controlling the lifecycle of dynamically allocated objects. They help developers avoid common pitfalls like memory leaks and dangling pointers. The standard library offers three main types: std::unique_ptr, std::shared_ptr, and std::weak_ptr. This guide covers they func ...
Posted on Sat, 25 Jul 2026 16:24:16 +0000 by trassalg
Implementing a Lightweight AOP Framework in C++11
Introduction to Aspect-Oriented Programming
Aspect-Oriented Programming (AOP) serves as a valuable supplement to Object-Oriented Programming (OOP) by addressing cross-cutting concerns. While OOP effectively models vertical, hierarchical relationships through inheritance, it struggles to encapsulate horizontal, shared behaviors that span across ...
Posted on Sat, 27 Jun 2026 16:37:03 +0000 by vjbrantner@purd
Understanding nullptr in Modern C++
The Problem with NULL
In C and C++, the NULL macro has been the traditional way to represent a null pointer. However, its definition differs between the two languages, leading to potential ambgiuities, especially in C++.
In C, NULL is typically defined as (void *) 0, a pointer to memory address zero. The C language allows implicit conversion fr ...
Posted on Thu, 11 Jun 2026 17:51:26 +0000 by sandeep251088
Disabling Functions in C++11 with the delete Specifier
Preventing Inheritance of Base Class Methods
In C++11, the = delete specifier provides a clean way to disable specific functions. This is particularly useful when you want to prevent a derived class from using certain member functions inherited from a base class.
Conisder a simple arithmetic class:
#include <iostream>
class BaseCalculato ...
Posted on Sat, 06 Jun 2026 17:58:11 +0000 by sbcwebs
Core C++ Knowledge Summary: Syntax, Memory, and Modern Features
Introduction
This document summarizes essential C++ concepts including syntax, memory management, and object-oriented programming.
1. C++ Fundamentals
1.1 Pointers and References
Differences Between Pointers and References
A pointer stores the address of an object. Its itself a variable (a named object) and has its own address, allowing pointer ...
Posted on Tue, 26 May 2026 18:46:23 +0000 by melittle
Modern C++ Core Features and Standard Library Enhancements
Standardization and Historical Context
The C++11 standard, ratified in 2011, marked a significant evolution from C++98/03. It introduced approximate 140 new features alongside numerous defect resolutions, transforming the language to better support modern system and library development with enhanced safety, efficiency, and programmer productivi ...
Posted on Tue, 26 May 2026 17:08:55 +0000 by Tonka1979
Understanding Rvalue References, Move Semantics, and Perfect Forwarding in Modern C++
Understanding Rvalue References, Move Semantics, and Perfect Forwarding in Modern C++
Distinguishing Value Categories
In C++11 and later, expressions are categorized into lvalues, prvalues, and xvalues. The latter two (xvalues and prvalues) are collectively known as rvalues. The primary practical distinction lies in whether the address of the e ...
Posted on Sat, 23 May 2026 20:12:00 +0000 by johnpaine