Zig Daily Report: A New Method for Zig and C++ Interoperability #276

Word count: 576, reading time approximately 3 minutes Zig C++ Interop[1] discusses interoperability between Zig and C++, particularly the issue of sharing data types between the two languages. The author’s goal is to allow both Zig and C to store each other’s data types within their respective structures/classes, without needing to define all Zig types … 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

Comprehensive Analysis of C++ Smart Pointer shared_ptr: From Principles to Practical Guide

Comprehensive Analysis of C++ Smart Pointer shared_ptr: From Principles to Practical Guide

1. Overview and Core Features <span>std::shared_ptr</span> is a smart pointer introduced in the C++11 standard library that implements the concept of shared ownership and automatically manages dynamically allocated memory resources through a reference counting mechanism. Compared to traditional raw pointers, <span>shared_ptr</span> significantly reduces the risks of memory leaks and dangling pointers, making it an indispensable … Read more

C++ Interview Weekly (7): Implementation Principles of unique_ptr and shared_ptr

C++ Interview Weekly (7): Implementation Principles of unique_ptr and shared_ptr

In C++, manual resource management (<span>new/delete</span>) is prone to errors, leading to: •Memory leaks•Double free•Exception safety issues To address these problems, C++11 introduced smart pointers: •<span>std::unique_ptr</span>: Exclusive ownership•<span>std::shared_ptr</span>: Shared ownership, managed through reference counting We will analyze from three dimensions: principles, performance, and application scenarios. 1. Technical Background and Design Intent 1unique_ptr• Goal: Exclusive resource … Read more

ByteDance C++ Second Interview: Implementing shared_ptr from Scratch

ByteDance C++ Second Interview: Implementing shared_ptr from Scratch

In the field of C++ development, smart pointers are an extremely important mechanism that greatly enhances the safety and convenience of memory management. Among them, shared_ptr is a key member of the smart pointer family, which uses reference counting to allow multiple pointers to share ownership of the same object. When the last shared_ptr pointing … Read more

In-Depth C++ Singleton Pattern: Principles, Implementation Comparisons, and shared_ptr Architecture Design

In-Depth C++ Singleton Pattern: Principles, Implementation Comparisons, and shared_ptr Architecture Design

#cpp #singleton 📌 In-Depth C++ Singleton Pattern: Principles, Implementation Comparisons, and shared_ptr Architecture Design 1️⃣ What is a Singleton? Basic Semantics and Usage Scenarios A Singleton ([[Singleton]]) is one of the most common object creation patterns, aimed at ensuring that a class has only one instance in the system and provides a global access point. … Read more

Water Quality Detection Based on Arduino

Water Quality Detection Based on Arduino

<span>TDS</span> (Total Dissolved Solids) is an indicator of the total amount of various inorganic and organic substances dissolved in water, usually expressed in milligrams per liter (mg/L) or parts per million (ppm). These substances include minerals such as calcium, magnesium, sodium, and potassium, as well as trace amounts of organic matter and heavy metals. This … Read more

Classic C++ Interview Question: Understanding Smart Pointers

Classic C++ Interview Question: Understanding Smart Pointers

Book Giveaway at the End 01 A Classic C++ Interview Question Is it difficult for beginners to pass interviews at major companies? Let’s first look at a classic C++ interview question. “Can you explain the principles and uses of smart pointers?” If students have memorized the strategies, they can probably say that smart pointers are … Read more

Measuring TDS with Laser-Making Technology

Measuring TDS with Laser-Making Technology

Previous Issues HomeExperiments | Is Your Living Environment Quiet? HomeExperiments | Drawing 24 Hours Of Light HomeExperiments | The Rate Of Cooling Of Water MakerTechnology And Science Class | Double Scale Experiment MakerTechnology And Science Class | Conductors And Insulators(1) MakerTechnology And Science Class | Conductors And Insulators(2) MakerTechnology And Science Class | Conductors And … Read more

C++ std::shared_ptr and std::weak_ptr: The End of Circular References

C++ std::shared_ptr and std::weak_ptr: The End of Circular References

In C++, forgetting to release dynamically allocated memory is a common pitfall for beginners. To address this issue, smart pointers have emerged. The smart pointer std::shared_ptr allows multiple pointers to share the same memory and manages its lifecycle through reference counting, which is very convenient. However, std::shared_ptr is not infallible; it has a fatal flaw: … Read more