C++ Mutex Optimization

C++ Mutex Optimization

Basics of Locks Locks are the core synchronization primitives in C++ concurrent programming, used to protect access to shared resources, ranging from simple variables to complex code segments. The C++11 standard library provides two core types of locks: mutex: an exclusive mutex, allowing only one thread to hold it at a time. shared_mutex: a shared-exclusive … Read more

Summary of C++ std::function Usage

Summary of C++ std::function Usage

<span>std::function</span> is a generic function wrapper introduced in C++11 (defined in the <span><functional></span> header), which can store, copy, and invoke any callable object (functions, lambda expressions, function pointers, functors, bind expressions, etc.), making it a core tool for callback mechanisms, event handling, and other scenarios. Basic Usage: Definition and Invocation <span>std::function</span> has a template parameter … Read more

New Features in C++11 Compared to C++98

C++11 is a milestone version in the development of the C++ language, also known as the beginning of modern C++. Compared to C++98, it introduces a large number of revolutionary features that fundamentally change the programming style of C++. 1. Core Basic Features of C++98 (1998) C++98 established the basic framework of C++, laying the … Read more

EntityX: A Powerful C++ Component

In the fields of game development and simulation systems, Entity Component System (ECS) architecture has become an important paradigm for building high-performance, maintainable complex systems. Among the many C++ ECS implementations, EntityX stands out for its deep utilization of C++11 features and type-safe component management. What is EntityX? EntityX is a high-performance, type-safe entity component … Read more

Advanced Guide to the C++ auto Keyword: Insights and Pitfalls from C++11 to C++17

Advanced Guide to the C++ auto Keyword: Insights and Pitfalls from C++11 to C++17 In the modern evolution of C++, the <span>auto</span> keyword is undoubtedly a revolutionary feature. It has transformed from a “chicken rib” in the C++98 era to a “power tool” in C++11 and later versions, greatly enhancing the simplicity and maintainability of … Read more

C++ Primer: Summary

“C++ Primer, Fifth Edition” is a classic textbook in the field of C++, comprehensively covering the core features of the C++11 standard, balancing syntax details with programming practices, making it suitable for both beginners and experienced developers looking to fill gaps in their knowledge.Below, we extract the core knowledge points of the book from four … Read more

In-Depth Analysis: How Significant is the Performance Gap Between C++11 `shared_ptr` and Raw Pointers?

In-Depth Analysis: How Significant is the Performance Gap Between C++11 `shared_ptr` and Raw Pointers?

For a period of time, I used <span>shared_ptr</span> throughout a server-side project, from construction to parameter passing and storage in containers, but the P99 jitter on a single path could not be suppressed. After gradually replacing the hot paths with <span>unique_ptr</span> / raw pointers, the latency tail significantly converged. This article will follow that review … Read more

Self-Implementation of C++17 Any Class

Self-Implementation of C++17 Any Class

Self-Implementation of C++17 Any Class 1. Introduction The Any class is a standard class introduced in C++17, included in the header file , with the core functionality of storing a single piece of data of any type, while the type does not need to be determined at compile time. It implements type erasure, making it … Read more

CS106L Lecture 3: C++11 List Initialization and Lvalues vs Rvalues

CS106L Lecture 3: C++11 List Initialization and Lvalues vs Rvalues

Hello everyone, today we will look at Lecture 3 of CS106L Spring 2025, which mainly introduces initialization, references, lvalues and rvalues, as well as the const qualifier. Starting with a Bug Today I took on a development requirement to set the directory path in a static member function of a class in a configurable way. … Read more

C++ Learning Manual – New Features 48 – Concurrency Programming (std::thread, std::async)

C++ Learning Manual - New Features 48 - Concurrency Programming (std::thread, std::async)

In modern computer architecture, concurrency programming has become a key technology for enhancing application performance. The C++11 standard introduced powerful support for concurrency programming, allowing developers to write multithreaded programs in a more intuitive and safer manner. Among these, <span>std::thread</span> and <span>std::async</span> are two of the most important tools for concurrency programming. 1. Why is … Read more