Building an Elegant C++ Cross-Platform Development and Build Workflow

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. C++ build issues have always been a hot topic, especially in various language wars, where they are often used as a negative example. Interestingly, most C++ programmers are often involved in maintaining existing systems, facing highly solidified, unchangeable build processes. The number of people who actually need to set up a project from scratch is in the minority. ...

2025-12-20 · Updated 2026-03-27 · 25 min · 5303 words · ykiko

Support AOT for CuTe DSL

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Why do we need AOT for CuTe DSL? CUTLASS C++ is a library for writing high-performance CUDA operators, known for its complexity and difficulty. To reduce the learning curve, NVIDIA introduced the Python-based CuTe DSL. Using Python instead of C++ templates for metaprogramming offers many benefits. First, users no longer have to struggle with the obscure template errors of C++, which is a major headache for C++ beginners; now they can focus on the code logic. Additionally, nvcc compilation is slow, and most of that time is spent in the compiler frontend, parsing C++ code. Especially for template-heavy libraries like CUTLASS, most of the time is spent processing template instantiations. Using CuTe DSL can bypass this issue. Compared to C++ code using CUTLASS, its compilation speed can be tens or even hundreds of times faster. Furthermore, operators and unit tests can now be written together in Python, which is much more convenient. ...

2025-11-11 · Updated 2025-11-17 · 7 min · 1313 words · ykiko

Clice, how have you been lately?

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Last night, I bought the domain name clice.io and deployed clice’s documentation website on it. There’s an indescribable joy in my heart. On one hand, I really like the clice.io domain; it looks very refined and beautiful. I actually had a few other candidates, such as .dev, but in the end, I chose this one, which is relatively more expensive (500 per year) but looks better. On the other hand, it signifies that clice has entered a new phase. ...

2025-07-24 · Updated 2025-07-25 · 3 min · 1343 words · ykiko

Reflection for C++26!!!

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. At the C++26 Sofia meeting, which just concluded yesterday, seven proposals related to Static Reflection: ...

2025-06-21 · Updated 2025-07-08 · 11 min · 5426 words · ykiko

Deep Dive into Clang (Part 1)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. After the article about clice was published, the response I received far exceeded my expectations, and many friends expressed a desire to participate in the development. While this enthusiasm is good, the barrier to entry is not low, mainly due to the difficulty of interacting with clang’s API. What makes it difficult? On the one hand, there is relatively little information about clang on the internet, whether in Chinese or English communities (this is expected, as there is very little demand for it, so naturally few people discuss it). On the other hand, due to the complexity of the C++ language itself, many details require a deeper understanding of the language before they can be grasped, and connecting theory with implementation is not easy. ...

2025-02-04 · Updated 2025-02-05 · 6 min · 2912 words · ykiko

Design and Implementation of a New C++ Language Server

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. It’s been several months since my last blog post. The reason for this long hiatus is that I’ve been busy working on clice – a brand new C++ language server. ...

2024-12-18 · Updated 2025-11-27 · 7 min · 3492 words · ykiko

St. Louis WG21 Meeting Review

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Due to a series of coincidences, I participated in last week’s WG21 meeting (the C++ Standards Committee meeting). Although I often browse new proposals for the C++ standard, I never expected to one day actually attend a WG21 meeting and get real-time updates on the latest progress of the C++ standard. Of course, this was my first time attending, and I was very excited. I’m writing this to record my feelings and the progress of the meeting. ...

2024-07-01 · Updated 2024-07-01 · 10 min · 2009 words · ykiko

The Perfect Combination of Python and C++: Object Design in pybind11

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. I participated in Google Summer of Code 2024. The main task was to implement a pybind11-compatible interface for a Python interpreter. Saying “implement a compatible interface” is somewhat of an understatement — it was essentially a rewrite of pybind11, so I’ve been spending a lot of time reading through its source code lately. ...

2024-06-07 · Updated 2024-12-02 · 4 min · 1694 words · ykiko

Is the singleton pattern in C++ truly a 'singleton'?

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Singleton Pattern is a common design pattern, often applied in scenarios such as configuration systems, logging systems, and database connection pools, where object uniqueness must be ensured. But can the Singleton Pattern truly guarantee a single instance? What are the consequences if uniqueness is not guaranteed? ...

2024-05-09 · Updated 2024-05-14 · 5 min · 2018 words · ykiko

Super easy-to-use C++ Online Compiler (VSCode Version)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Compiler Explorer is a very popular online C++ compiler, which can be used to test different compilation and execution environments, or to share code. As a C++ enthusiast, I interact with it almost every day, and its frequency of use far exceeds my imagination. At the same time, I am also a heavy VSCode user, completing almost everything within VSCode. Considering that I often write code locally and then copy it to Compiler Explorer, it always felt uncomfortable. Sometimes I would directly modify it on its web editor, but without code completion, that was also uncomfortable. Therefore, I collaborated with @iiirhe to write this extension Compiler Explorer for VSCode, which integrates Compiler Explorer into VSCode based on the API provided by Compiler Explorer, allowing users to directly use Compiler Explorer’s features within VSCode. ...

2024-04-24 · Updated 2024-05-04 · 3 min · 626 words · ykiko

Thoroughly Understanding C++ ABI

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Application Binary Interface, or ABI as we commonly call it, is a concept that feels both familiar and unfamiliar. Familiar in what sense? It’s often discussed when troubleshooting, frequently mentioned in articles, and sometimes we even have to deal with compatibility issues it causes. Unfamiliar in what sense? If someone asks you what an ABI is, you’ll find that you know what it’s about, but describing it in precise language is quite difficult. In the end, you might just resort to saying, as WIKI does: an ABI is an interface between two binary program modules. Is there a problem with that? No, as a general description, it’s sufficient. But it can feel a bit hollow. ...

2024-04-16 · Updated 2025-12-24 · 11 min · 5285 words · ykiko

Where exactly does C++ code bloat occur?

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Readers probably often hear people say that C++ code suffers from severe binary bloat, but usually few people point out the specific reasons. After a search online, I found that there aren’t many articles that delve deeply into this issue. The above statement is more like part of a cliché, passed down by word of mouth, but few can explain why. Today, your editor ykiko will take everyone on a journey to explore the ins and outs of C++ code bloat (^ω^) ...

2024-03-11 · Updated 2024-12-24 · 9 min · 4209 words · ykiko

The History of constexpr in C++! (Part Two)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Prequel: The History of constexpr in C++! (Part One) 2015-2016: Syntactic Sugar for Templates In C++, there are many templates that support full specialization, but not many that support partial specialization. In fact, only class templates and variable templates support it. Variable templates can actually be seen as syntactic sugar for class templates, so rounding it up, only class templates truly support partial specialization. The lack of partial specialization can make some code very difficult to write. ...

2024-02-22 · Updated 2024-11-30 · 8 min · 3751 words · ykiko

The History of constexpr in C++! (Part One)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. A few months ago, I wrote an article introducing C++ templates: Looking at Flowers in a Fog: A True Understanding of C++ Templates. ...

2024-02-10 · Updated 2024-12-18 · 9 min · 4485 words · ykiko

How to elegantly convert enum to string in C++?

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. no hard code Define an enum enum Color { RED, GREEN, BLUE }; Try to print ...

2024-01-29 · Updated 2025-07-08 · 8 min · 1533 words · ykiko

Relocate Semantics in C++

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. As is well known, there are currently two special constructors in C++: the copy constructor and the move constructor. ...

2024-01-25 · Updated 2024-12-18 · 5 min · 2383 words · ykiko

A 7-Year Relay Race: Getting the Number of Fields in a C++ Struct

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Introduction In C++17, a feature called “structured binding” was introduced. This feature is similar to pattern matching in other languages and allows us to conveniently access members of a struct. ...

2023-12-25 · Updated 2025-01-14 · 10 min · 4693 words · ykiko

Implement Object in C++!

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Static and Dynamic The terms static typing and dynamic typing are probably familiar to everyone. The key to distinguishing between them lies in the timing of type checking. What does that mean? ...

2023-12-03 · Updated 2024-11-30 · 4 min · 1831 words · ykiko

Why is it said that C/C++ compilers do not preserve metadata?

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. First, what is metadata? Consider the following python code. We want to automatically modify the corresponding field value based on the input string. ...

2023-12-03 · Updated 2024-11-30 · 4 min · 1968 words · ykiko

Master your C++ code with Clang tools.

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Clang is a C-language family compiler frontend provided by the LLVM project. It was originally developed to replace the C language frontend of the GNU Compiler Collection (GCC), with the goal of providing faster compilation speeds, better diagnostic information, and a more flexible architecture. Clang includes C, C++, and Objective-C compiler frontends, which are designed to be embedded in other projects. A key feature of Clang is its modular architecture, which makes it easier for developers to extend and customize compiler functionality. Clang is widely used in many projects, including LLVM itself, the development of some operating system kernels, and the implementation of compilers for some programming languages. ...

2023-11-29 · Updated 2024-11-30 · 6 min · 2919 words · ykiko

Various approaches to code generation

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Introduction Let’s take a recent requirement as an introduction. We all know that Markdown can use lang to fill in code blocks and supports code highlighting. However, I wanted to support my own custom code highlighting rules and encountered the following problems: ...

2023-11-29 · Updated 2024-11-30 · 4 min · 1820 words · ykiko

A Reflection Tutorial for C++ Programmers

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. What is Reflection? The term Reflection is probably not new to anyone; perhaps you haven’t used it, but you’ve certainly heard of it. However, like many other idiomatic terms in the CS field, there isn’t a clear and precise definition for reflection. This leads to a situation where, for languages like C#, Java, and Python that have reflection, discussing it naturally brings to mind related facilities, APIs, and code examples in those languages, making it very concrete. But for languages like C, C++, and Rust, which don’t have reflection, when reflection is discussed, people are often unsure what the other person is referring to, making it very abstract. For example, someone might tell me that Rust has reflection, and the example they provide is the introduction to std::Any module in Rust’s official documentation. It mentions: ...

2023-11-29 · Updated 2024-10-21 · 3 min · 1234 words · ykiko

C++26 Static Reflection Proposal Analysis

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Recently, I’ve been planning to write a series of articles discussing the concept of reflection in detail. Coincidentally, C++26 has a new reflection proposal, and I noticed there aren’t many related articles on Zhihu, despite this topic being frequently discussed. So, I’m taking this opportunity to talk about static reflection in C++, as a warm-up for the series. ...

2023-10-16 · Updated 2025-06-22 · 5 min · 2398 words · ykiko

C++ Pointers to Members: A Comprehensive Guide

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. Introduction In C++, an expression like &T::name returns a pointer to member. It’s occasionally used when writing code, but this concept might not be familiar to many. Consider the following code: ...

2023-10-04 · Updated 2024-12-18 · 11 min · 2302 words · ykiko

Seeing Through the Fog: A True Understanding of C++ Templates

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. The concept of templates in C++ has existed for over twenty years. As one of the language’s most important constructs, there is no shortage of related discussion. Unfortunately, truly in-depth and valuable discussions are rare — especially those that examine the feature from multiple perspectives. Many articles on templates tend to entangle the topic with various syntactic details, easily leaving readers with a hazy impression. Similar things happen elsewhere: introductions to coroutines often mix them with all kinds of I/O concerns, and discussions of reflection seem confined to reflection in Java or C#. This isn’t unreasonable, but it often leaves readers unable to grasp the essence. After consuming a lot of content, one still can’t get to the heart of the matter, and it becomes easy to conflate different concepts. ...

2023-09-12 · Updated 2025-12-24 · 10 min · 4653 words · ykiko

C++ Forbidden Black Magic: STMP (Part 2)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. In the previous article, we gained a preliminary understanding of the principles of STMP and used it to implement a simple compile-time counter. However, its power extends far beyond that. This article will discuss some advanced applications based on STMP. ...

2023-07-30 · Updated 2026-03-14 · 8 min · 1593 words · ykiko

C++ Forbidden Black Magic: STMP (Part 1)

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. As is well known, traditional C++ constant expression evaluation neither depends on nor changes the global state of the program. For any identical input, its output is always the same, and it is considered purely functional. Template Meta Programming, as a subset of constant evaluation, should also adhere to this rule. ...

2023-07-29 · Updated 2026-03-14 · 11 min · 2137 words · ykiko

std::variant is hard to use!

This article was translated by AI using Gemini 2.5 Pro from the original Chinese version. Minor inaccuracies may remain. std::variant was added to the standard library in C++17. This article will discuss the background of its inclusion and some issues related to its usage. ...

2023-07-25 · Updated 2024-07-20 · 3 min · 1407 words · ykiko